Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem] Ubuntu installation attempt conflicts with libscotchmetis-dev #445

Open
ACREtheMaker opened this issue Feb 10, 2024 · 2 comments

Comments

@ACREtheMaker
Copy link

When I try to install ElmerFEM-CSC on Ubuntu (running on WSL2 Windows 11) using ppa:elmer-csc-ubuntu/elmer-csc-ppa it wants to install libmetis-dev which will force remove libscotchmetis-dev that other programs need. Isn't it possible to use libscotchmetis-dev or better libscotchparmetis-dev to replace this functionality?

Will I run into problems if I try to compile from source myself using libscotchmetis-dev or libscotchparmetis-dev?

If not, please consider uploading compiled versions of both setups on ppa:elmer-csc-ubuntu/elmer-csc-ppa

@ACREtheMaker
Copy link
Author

Seems like the source code is not yet updated to make use of scothparmetis and scotchmetis so I compiled a local version of libparmetis that I linked to a compilation of ElmerFEM. For anyone interested here are the steps I followed:

  1. I am running Ubuntu 22.04lts on WSL2 Windows 11
  2. install all required libraries using the ubuntu Launchpad repositories as explained here except do NOT install libparmetis-dev. I will assume you will use the "-int64" indexing variation of the libraries as I have.
  3. go into /usr/local: cd /usr/local
  4. make a bash script called make_elmerfem.sh and copy in the following script:
#!/bin/bash

# Get ElmerFEM source code
srcdir=$(pwd)/elmerfem
builddir=${srcdir}/build
git clone --recursive https://github.com/ElmerCSC/elmerfem.git elmerfem

# Get ParMetis source code for local build, all other dependencies manually installed using apt or synaptic for ubuntu
parmetis_srcdir=$(pwd)/elmerfem/parmetis
parmetis_installdir=${parmetis_srcdir}/install-int64
git clone --recursive https://git.launchpad.net/ubuntu/+source/parmetis elmerfem/parmetis

# select 64-bit indexing and double precision real numbers
sed -i -e "s/#define IDXTYPEWIDTH 32/#define IDXTYPEWIDTH 64/g" ${srcdir}/elmergrid/src/metis-5.1.0/include/metis.h
sed -i -e "s/#define IDXTYPEWIDTH 32/#define IDXTYPEWIDTH 64/g" ${parmetis_srcdir}/metis/include/metis.h
sed -i -e "s/#define REALTYPEWIDTH 32/#define REALTYPEWIDTH 64/g" ${srcdir}/elmergrid/src/metis-5.1.0/include/metis.h
sed -i -e "s/#define REALTYPEWIDTH 32/#define REALTYPEWIDTH 64/g" ${parmetis_srcdir}/metis/include/metis.h

# Build parmetis
cd ${parmetis_srcdir}
make config openmp=ON prefix=${parmetis_installdir} 
make openmp=ON prefix=${parmetis_installdir} install

# Collect parmetis dependencies for ElmerFEM
parmetis_lib_dir=${parmetis_installdir}/lib
parmetis_lib=${parmetis_lib_dir}/libparmetis.a
parmetis_include_dir=${parmetis_installdir}/include

# Build ElmerFEM
mkdir -p ${builddir}
cd ${builddir}

#FC=gfortran CC=gcc CXX=g++ LDFLAGS="-m64" FCLAGS="-m64 -fallow-argument-mismatch" FFLAGS="-m64 -fallow-argument-mismatch -fallow-invalid-boz" cmake \
cmake \
	-S ${srcdir} \
	-B ${builddir} \
	-DCMAKE_INSTALL_PREFIX=install \
	-DCMAKE_BUILD_TYPE=Release \
	-DWITH_QT5=TRUE \
	-DWITH_ELMERGUI:BOOL=TRUE \
	-DWITH_OpenMP:BOOLEAN=TRUE \
	-DWITH_MPI:BOOL=TRUE \
	-DWITH_Mumps:BOOL=TRUE \
	-DWITH_LUA:BOOL=TRUE \
	-DMetis_INCLUDE_DIR=/usr/include/metis-int64 \
	-DMetis_LIBRARIES=/usr/lib/x86_64-linux-gnu/metis-int64/libmetis.a \
	-DParMetis_INCLUDE_DIR=${parmetis_include_dir} \
	-DParMetis_LIBRARIES=${parmetis_lib} \
	-DCMAKE_CUDA_FLAGS="-cudart shared" \
	-DCUDA_USE_STATIC_CUDA_RUNTIME=OFF \
	-DCMAKE_C_FLAGS="-m64 -DARCH-D_GNU_SOURCE -pthread -fopenmp -I/opt/nvidia/hpc_sdk/Linux_x86_64/2024/cuda/include -I/opt/nvidia/hpc_sdk/Linux_x86_64/2024/math_libs/include" \
	-DCMAKE_CXX_FLAGS="-m64 -Wno-deprecated-declarations" \
	..

# Install ElmerFEM
make -j install 
mkdir -p /usr/local/bin/ElmerFEM
ln -sf /usr/local/elmerfem/build/install/bin/* /usr/local/bin/ElmerFEM/.
  1. make sure there is no folder call "/usr/local/elmerfem" or delete it first.
  2. run the compilation script: sudo bash make_elmerfem.sh
  3. if all goes well there should be binaries in /usr/local/bin/ElmerFEM/
  4. run the ElmerGUI binary depending on how your environmental variable PATH is setup: ElmerFEM/ElmerGUI

@tiagomoraismorgado
Copy link

this seems to work for me

# Download CUDA pin file
#wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
#sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600

# Download CUDA repository package
#wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda-repo-wsl-ubuntu-12-4-local_12.4.0-1_amd64.deb

'''

# Update package lists
sudo apt update

# Upgrade packages
sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt full-upgrade -y

sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test

sudo dpkg --configure -

sudo apt update

sudo apt install gcc-12 g++-12 gcc-13 g++-13 -y

sudo dpkg --configure -

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 --slave /usr/bin/g++ g++ /usr/bin/g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13 --slave /usr/bin/g++ g++ /usr/bin/g++-13

sudo dpkg --configure -

sudo update-alternatives --config gcc

sudo dpkg --configure -

gcc --version

sudo apt install build-essential
sudo apt install libmpfr-dev libgmp3-dev libmpc-dev -y
wget http://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz
#tar -xf gcc-13.2.0.tar.gz

sudo dpkg --configure -

cd gcc-13.2.0

sudo dpkg --configure -

./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-13.2.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-13.2.0

sudo dpkg --configure -

make -j3
sudo make install

sudo dpkg --configure -

/usr/local/gcc-13.2.0/bin/gcc-13.2.0 --version

sudo dpkg --configure -

# Install required packages
sudo apt install -y \
    libxkbcommon0=1.6.0-1 \
    fakeroot \
    libalgorithm-merge-perl \
    g++=4:13.2.0-7 \
    cpp-x86-64-linux-gnu=4:13.2.0-7 \
    g++-13>=13.2.0-11 \
    g++-x86-64-linux-gnu=4:13.2.0-7 \
    gcc-13>=13.2.0-11 \
    gcc=4:13.2.0-7 \
    gcc-x86-64-linux-gnu=4:13.2.0-7 \
    libglvnd0=1.7.0-1 \
    lto-disabled-list \
    openjdk-17-jre-headless=17.0.10+7-1~22.04.1 \
    libatk-wrapper-java-jni>=0.30.4-0ubuntu2 \
    cpp=4:13.2.0-7 \
    cpp-x86-64-linux-gnu=4:13.2.0-7 \
    g++-13>=13.2.0-11~ \
    g++-x86-64-linux-gnu=4:13.2.0-7 \ 
    gcc-13>=13.2.0-11~ \
    gcc=4:13.2.0-7 \
    cpp-x86-64-linux-gnu=4:13.2.0-7 \ 
    gcc-13>=13.2.0-11~ \
    gcc-x86-64-linux-gnu=4:13.2.0-7 \ 
    openjdk-17-jre-headless=17.0.10+7-1~22.04.1 \
    libatk-wrapper-java-jni>=0.30.4-0ubuntu2

'''

# Install CUDA repository
sudo dpkg -i cuda-repo-wsl-ubuntu-12-4-local_12.4.0-1_amd64

# Copy CUDA keyring
sudo cp /var/cuda-repo-wsl-ubuntu-12-4-local/cuda-*-keyring.gpg /usr/share/keyrings/

# Update package lists
sudo apt-get update

# Install CUDA toolkit
sudo apt-get -y install cuda-toolkit-12-4

# Install pycuda (optional)
#sudo pip3 install pycuda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants