安装pycuda的一个问题

开始的命令如下

sudo pip3 install 'pycuda>=2017.1.1'

报错

x86_64-linux-gnu-gcc -pthread -fwrapv -Wall -O3 -DNDEBUG -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DBOOST_PYTHON_SOURCE=1 -Dboost=pycudaboost -DPYGPU_PYCUDA=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_DONT_USE_CHRONO=1 -DPYGPU_PACKAGE=pycuda -DBOOST_THREAD_BUILD_DLL=1 -DHAVE_CURAND=1 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION=1 -Isrc/cpp -Ibpl-subset/bpl_subset -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/include/python3.5m -c src/cpp/cuda.cpp -o build/temp.linux-x86_64-3.5/src/cpp/cuda.o
    In file included from src/cpp/cuda.cpp:1:0:
    src/cpp/cuda.hpp:14:18: fatal error: cuda.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ll1d1lgw/pycuda/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-_8hro8ox/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-ll1d1lgw/pycuda/
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

使用pip -vvv install pycuda
显示nvcc找不到

 ***************************************************************
    *** WARNING: nvcc not in path.
    *** May need to set CUDA_INC_DIR for installation to succeed.
    ***************************************************************

解决方式

切换到root用户
sudo su -
pip install pycuda
安装成功

sudo 的环境变量

# sudo env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

你可能感兴趣的:(安装pycuda的一个问题)