NiftyPET / NIPET

High-throughput PET image reconstruction with high quantitative accuracy and precision
Apache License 2.0
29 stars 7 forks source link

NVIDIA CUDA Toolkit 9.1 from Ubuntu build error #35

Open paskino opened 3 years ago

paskino commented 3 years ago

On a Ubuntu 18.04 I cannot build NiftyPET. See https://github.com/SyneRBI/SIRF-SuperBuild/issues/494

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

I ran


sudo apt update
sudo apt upgrade
sudo apt install python3-dev
sudo apt install nvidia-cuda-toolkit
sudo snap install --classic cmake
wget https://raw.githubusercontent.com/pypa/get-pip/master/get-pip.py
python3 get-pip.py --user
python3 -m pip install --user 'numpy==1.19.5'  # no need to specify version. just testing...
git clone https://github.com/NiftyPET/NIPET nipet
mkdir nipet/build
cd nipet/build
cmake ../niftypet && cmake --build .

Error

[  4%] Building CUDA object nipet/CMakeFiles/mmr_auxe.dir/src/aux_module.cu.o
cd /home/ofn77899/nipet/build/nipet && /usr/bin/nvcc  -Dmmr_auxe_EXPORTS -I/home/ofn77899/nipet/niftypet/nipet/src -I/usr/include/python3.6m -I/home/ofn77899/.local/lib/python3.6/site-packages/numpy/core/include -I/home/ofn77899/nipet/niftypet/nipet/include -O3 -DNDEBUG --generate-code=arch=compute_30,code=[compute_30,sm_30] -Xcompiler=-fPIC -std=c++14 -x cu -c /home/ofn77899/nipet/niftypet/nipet/src/aux_module.cu -o CMakeFiles/mmr_auxe.dir/src/aux_module.cu.o
/home/ofn77899/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h(84): error: expected a "}"

/home/ofn77899/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h(89): warning: parsing restarts here after previous syntax error

/home/ofn77899/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h(450): error: identifier "NPY_NTYPES_ABI_COMPATIBLE" is undefined

2 errors detected in the compilation of "/tmp/tmpxft_00005c59_00000000-6_aux_module.cpp1.ii".

I then tried to install CUDA Toolkit from NVidia, and got 10.1. With it it works, both with conda and stock python.

Maybe 9.1, which is installed by Ubuntu is not sufficient for NiftyPET?

casperdcl commented 3 years ago

I think cuda 9.2 (which is quite old now) requires an old g++ (<7.3) yet based on https://github.com/SyneRBI/SIRF-SuperBuild/issues/494#issuecomment-781279670 you have 7.5.

The cuda compiler version has to be compatible with the C++ compiler. The usual way of installing CUDA is via https://developer.nvidia.com/cuda-toolkit-archive, which firstly uses apt-get install cuda rather than nvidia-cuda-toolkit and secondly doesn't even provide CUDA 9 for Ubuntu 18.04.

Don't mix and match deprecated things with new things!

casperdcl commented 3 years ago

By any chance, does replacing -std=c++14 with -std=c++11 fix things for you?

paskino commented 3 years ago

I installed nvidia-cuda-toolkit following a suggestion of ubuntu itself after I called nvcc on the machine where it wasn't installed!

-std=c++11 doesn't help.