CUDA PATH 关系(通过重写您的环境)

CUDA PATH 关系(通过重写您的环境)

我正在尝试安装 chainer-cude-deps。当我尝试安装 ( sudo pip install chainer-cuda-deps) 时,出现以下错误:

    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
     #include <cuda.h>
                      ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-sLLkNT/pycuda/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-OAHHif-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-sLLkNT/pycuda

这是按照以下步骤进行的:

sudo pip install chainer
sudo dpkg -i cuda-repo-ubuntu1410-7-0-local_7.0-28_amd64.deb

我应该怎么做才能尝试安装 chainer-cuda-deps?

答案1

这是pycuda的问题。pycuda setup.py检查nvcc命令,并猜测CUDA的根目录。

https://github.com/inducer/pycuda/blob/master/setup.py#L30

...,然后它设置CUDA的包含目录。

https://github.com/inducer/pycuda/blob/master/setup.py#L93

您需要做的就是在之前正确设置路径pip

PATH=/usr/local/cuda-7.0/bin:$PATH
pip install chainer-cuda-deps

请尝试一下!

答案2

我也遇到了同样的错误。也许你的 pycuda 没有正确安装。请尝试从源安装 pycuda,而不是 pip。

如果无法从源安装pycuda,则存在诸如CUDA本身的路径搞笑之类的风险。

最终在Ubuntu14.04上,我们在配置CUDA7.0上成功搭建了pycuda和chainer环境。

顺便写一下我的环境

假设#CUDA 已正确安装

#CUDA Relationship of PATH (by rewriting your environment)
CUDA_ROOT=/usr/local/cuda-7.0

PATH=$PATH:/usr/local/cuda-7.0/bin

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.0/lib64:/usr/local/cuda-7.0/lib

CPATH=$CPATH:/usr/local/cuda-7.0/include

CUDA_INC_DIR=/usr/local/cuda-7.0/bin:$CUDA_INC_DIR

#Installing from source of #pycuda
git clone --recursive http://git.tiker.net/trees/pycuda.git
cd pycuda
python configure.py
sudo python setup.py install
sudo make install

祝你好运。

答案3

顺便写一下我的环境

假设#CUDA 已正确安装

CUDA PATH 关系(通过重写您的环境)

CUDA_ROOT=/usr/local/cuda-7.0

PATH=$PATH:/usr/local/cuda-7.0/bin

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.0/lib64:/usr/local/cuda-7.0/lib

CPATH=$CPATH:/usr/local/cuda-7.0/include

CUDA_INC_DIR = /usr/local/cuda-7.0/bin:$CUDA_INC_DIR

从#pycuda 源安装

git clone --recursivehttp://git.tiker.net/trees/pycuda.git cd pycuda python configure.py sudo python setup.py 安装 sudo make install

相关内容