简体   繁体   English

pycuda失败; Theano和Anaconda

[英]pycuda fail; Theano with Anaconda

I'm using Anaconda to install Theano on MacOSX (Mavericks 10.9 ), just like this post explains: " How to make Theano operate on Mac Lion? " 我正在使用Anaconda在MacOSX(Mavericks 10.9)上安装Theano,就像这篇文章解释的那样:“ 如何使Theano在Mac Lion上运行?

theano.test() theano.test()

This command gives the same error as in the post above. 该命令给出与上述文章相同的错误。 It gives that error on an Ubuntu 14.1, System 76 as well. 它也会在Ubuntu 14.1和System 76上出现该错误。

I am able to import commands from Theano; 我能够从Theano导入命令; but I still would like to understand why theano.test() fails. 但我仍然想了解theano.test()为何失败。 The packages CUDA and Boost were already installed before running... 在运行之前已经安装了CUDA和Boost软件包。

(Reference: See section: " Testing your Installation " http://deeplearning.net/software/theano/install.html ) (参考:请参见“ 测试安装 ”一节: http://deeplearning.net/software/theano/install.html

As the post suggests, I assumed the fix would come from installing the XCode command line, homebrew, and pycuda. 正如文章所暗示的那样,我认为此修复程序将来自安装XCode命令行,自制程序和pycuda。 The first two were installed just fine. 前两个安装得很好。 But pycuda fails: 但是pycuda失败了:

pip install pycuda pip安装pycuda

....gives the following error: ....给出以下错误:

    > src/cpp/cuda.cpp -o build/temp.macosx-10.5-x86_64-3.4/src/cpp/cuda.o
    >     In file included from src/cpp/cuda.cpp:1:

> 
>     src/cpp/cuda.hpp:14:10: fatal error: 'cuda.h' file not found
>     #include <cuda.h>

>              ^
>     1 error generated.
>     error: command 'gcc' failed with exit status 1
>  


    >    Command "//anaconda/bin/python3 -c "import setuptools,

    >tokenize;__file__='/private/var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-build-4raihcb4/pycuda/setup.py';exec(compile(getattr(tokenize,
    > 'open', open)(__file__).read().replace('\r\n', '\n'), __file__,
    > 'exec'))" install --record
    > /var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-kr_3ws22-record/install-record.txt



    >> --single-version-externally-managed --compile" failed with error code 1 in

    > /private/var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-build-4raihcb4/pycuda

It seems like the first error (gcc failed) is that the complier is not finding gcc. 似乎第一个错误(gcc失败)是编译器未找到gcc。 (Note again: I installed the MacOSX command line tools) (再次注意:我安装了MacOSX命令行工具)

I run 我跑

which gcc 

this gives usr/bin/gcc 这给出了usr / bin / gcc

I also tried : 我也尝试过:

python configure.py --cuda-root=/usr/local/cuda
--cuda-inc-dir=/Developer/NVIDIA/CUDA-5.5/include --cudart-lib-dir=/Developer/NVIDIA/CUDA-5.5/lib

That didn't work as well. 那也没有用。

Has anyone else had this difficulty installing pycuda and can make a recommendation here? 有没有其他人在安装pycuda时遇到困难,可以在这里提出建议? Thanks. 谢谢。

The first error is not indicating that gcc failed to be found, rather it is saying that gcc reported an error and that error was that the file cuda.h could not be found. 第一个错误并不表示找不到gcc ,而是表示gcc报告了一个错误,该错误是找不到文件cuda.h

That error suggests you don't have the CUDA toolkit installed. 该错误表明您未安装CUDA工具包。 You need to install this before proceeding to install PyCUDA. 您需要先安装此软件,然后才能安装PyCUDA。 The CUDA toolkit can be downloaded from NVIDIA's website . CUDA工具包可从NVIDIA网站下载

The PyCUDA web page indicates that it has the following prerequisites: BOOST, CUDA, and Numpy. PyCUDA网页表明它具有以下先决条件:BOOST,CUDA和Numpy。

I resolved this same issue with a combination of two things: 我通过结合以下两种方法解决了同一问题:

  1. Making sure nvcc is in your PATH seems resolve the compilation errors. 确保nvcc在您的PATH似乎可以解决编译错误。 If you then encounter the following linking error: 如果然后遇到以下链接错误:

    ld: file not found: @rpath/CUDA.framework/Versions/A/CUDA for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

  2. I fixed it changing the @rpath reference in libcuda.dylib to an absolute path: 我修复了将libcuda.dylib中的@rpath引用更改为绝对路径的问题:
    install_name_tool -change @rpath/CUDA.framework/Versions/A/CUDA \\ /Library/Frameworks/CUDA.framework/CUDA \\ /usr/local/cuda/lib/libcuda.dylib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM