DIDSR / VICTRE_MCGPU

Version of MC-GPU used in the VICTRE project
32 stars 18 forks source link

Compiling instructions for new CUDA #11

Open rodrigovimieiro opened 2 years ago

rodrigovimieiro commented 2 years ago

Not really an issue. Just to help others who want to compile with new versions of CUDA.

CUDA Samples are not found in local installation anymore. Based on NVIDIA samples README:

Beginning in the next CUDA release, samples will be relocating from a local installation to GitHub! Please refer to our online repository for the most up-to-date CUDA samples and library examples: https://github.com/nvidia/cuda-samples

So, these are the steps:

  1. git clone https://github.com/NVIDIA/cuda-samples.git;
  2. Change -I/usr/local/cuda/samples/common/inc -I/usr/local/cuda/samples/shared/inc/ to -I/yourPath/cuda-samples/Common/ in the make_MC-GPU_v1.5b.sh file;
  3. Also, if using MPI, you need to install it sudo apt install libopenmpi-dev and the mpicc -showme command shows the path to the necessary libraries to compile mpi projects (based on this answer). Then substitute -I/usr/include/openmpi -L/usr/lib/ -lmpi with the output from the previous command.

This command works for me:

nvcc MC-GPU_v1.5b.cu -o MC-GPU_v1.5b.x -m64 -O3 -use_fast_math -DUSING_MPI -I. -I/usr/local/cuda/include -I/home/rodrigo/NVIDIA_CUDA-11.5_Samples/cuda-samples/Common/ -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/include -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi -lz --ptxas-options=-v -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_61,code=sm_61

Environment:

jerichooconnell commented 2 years ago

Not really an issue either but I thought it would be good for me as much as anyone to leave instructions to run MCGPU on docker on a similar note to @rodrigovimieiro

First you need to install docker to work with your gpu drivers:

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html

Then:

  1. Pull the nvidia docker image docker pull nvidia/cuda:11.2.1-devel-ubuntu20.04 or whichever docker version you would like.
  2. Run the docker instance interactively with your shell using your gpu docker run -it --gpus all nvidia/cuda:11.2.0-devel-ubuntu20.04 bash
  3. Install libraries that you need:
    apt-get update # update apt listings
    apt install zlib1g-dev
    apt install openmpi-dev
    apt install git-all
    apt install vim # optional for editing the makefile
  4. Follow the steps above for cloning the cuda samples and changing the makefile
  5. I had to include the compute 75 instructions in the makefile to get mine to run:
nvcc MC-GPU_v1.5b.cu -o MC-GPU_v1.5b.x -m64 -O3 -use_fast_math -DUSING_MPI -I. -I/usr/local/cuda/include -I/root/cuda-samples/Common/ -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/include -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi -lz --ptxas-options=-v -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_75,code=sm_75

Environment (locally, so shouldn't really matter other than GPU):