ModuleNotFoundError: No module named 'cupy', cupy 安装出错

ModuleNotFoundError: No module named 'cupy', cupy 安装出错

    • 没有cupy module
    • 使用pip安装cupy
    • 输入命令
      • output
      • 根据你自己电脑上的cuda版本选择cupy
      • 最后命令

https://github.com/cupy/cupy/issues/1007

没有cupy module

 ModuleNotFoundError: No module named 'cupy'

使用pip安装cupy

$ pip install cupy #报错

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting cupy
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fa/62/8a245b23fbd1bb57da0925ae45cc6d5ed163fedf37323242bfa30b45f07d/cupy-6.4.0.tar.gz (3.1MB)
     |████████████████████████████████| 3.1MB 361kB/s 
    ERROR: Command errored out with exit status 1:
     command: /home/superzou/.pyenv/versions/3.6.9/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rb78h9nw/cupy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rb78h9nw/cupy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info        
         cwd: /tmp/pip-install-rb78h9nw/cupy/                                                              
    Complete output (46 lines):                                                                            
    Options: {'package_name': 'cupy', 'long_description': None, 'wheel_libs': [], 'wheel_includes': [], 'no_rpath': False, 'profile': False, 'linetrace': False, 'annotate': False, 'no_cuda': False}                 
                                                                                                           
    -------- Configuring Module: cuda --------                                                             
    /tmp/tmpmr13pdbp/a.cpp:1:10: fatal error: cublas_v2.h: No such file or directory                       
     #include                                                                                 
              ^~~~~~~~~~~~~                                                                                
    compilation terminated.                                                                                
    command 'gcc' failed with exit status 1                                                                
                                                                                                           
    ************************************************************                                           
    * CuPy Configuration Summary                               *                                           
    ************************************************************                                           
                                                                                                           
    Build Environment:                                                                                     
      Include directories: []                                                                              
      Library directories: []                                                                              
      nvcc command       : (not found)                                                                     
                                                                                                           
    Environment Variables:                                                                                 
      CFLAGS          : (none)                                                                             
      LDFLAGS         : (none)                                                                             
      LIBRARY_PATH    : (none)                                                                             
      CUDA_PATH       : (none)                                                                             
      NVTOOLSEXT_PATH : (none)                                                                             
      NVCC            : (none)                                                                             
                                                                                                           
    Modules:                                                                                               
      cuda      : No                                                                                       
        -> Include files not found: ['cublas_v2.h', 'cuda.h', 'cuda_profiler_api.h', 'cuda_runtime.h', 'cufft.h', 'curand.h', 'cusparse.h', 'nvrtc.h']                                                                
        -> Check your CFLAGS environment variable.                                                         
                                                                                                           
    ERROR: CUDA could not be found on your system.                                                         
    Please refer to the Installation Guide for details:                                                    
    https://docs-cupy.chainer.org/en/stable/install.html                                                   
                                                                                                           
    ************************************************************                                           
                                                                                                           
    Traceback (most recent call last):                                                                     
      File "", line 1, in <module>                                                                 
      File "/tmp/pip-install-rb78h9nw/cupy/setup.py", line 120, in <module>                                
        ext_modules = cupy_setup_build.get_ext_modules()                                                   
      File "/tmp/pip-install-rb78h9nw/cupy/cupy_setup_build.py", line 632, in get_ext_modules              
        extensions = make_extensions(arg_options, compiler, use_cython)
      File "/tmp/pip-install-rb78h9nw/cupy/cupy_setup_build.py", line 387, in make_extensions
        raise Exception('Your CUDA environment is invalid. '
    Exception: Your CUDA environment is invalid. Please check above error log.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

输入命令

$ pip search cupy

output

cupy (6.4.0)              - CuPy: NumPy-like API accelerated with CUDA
cupy-cuda91 (6.4.0)       - CuPy: NumPy-like API accelerated with CUDA
cupy-cuda92 (6.4.0)       - CuPy: NumPy-like API accelerated with CUDA
cupy-cuda100 (6.4.0)      - CuPy: NumPy-like API accelerated with CUDA
cupy-cuda90 (6.4.0)       - CuPy: NumPy-like API accelerated with CUDA
cupy-cuda80 (6.4.0)       - CuPy: NumPy-like API accelerated with CUDA
cupy-cuda101 (6.4.0)      - CuPy: NumPy-like API accelerated with CUDA
cupy-ibmopt (4.0.0a3)     - CuPy: NumPy-like API accelerated with CUDA (opbimized for POWER machines by
                            IBM)
clpy (0.0.0a0)            - ClPy: OpenCL backend for CuPy
.....后面省略

根据你自己电脑上的cuda版本选择cupy

比如我电脑上是cuda10.0 我就选 cupy-cuda100.
如果cuda9.0 我就选 cupy-cuda90

最后命令

pip install cupy-cuda100

你可能感兴趣的:(编程环境配置)