昇腾社区quadruped-robot 环境配置 安装 cupy失败,报错 ‘Your CUDA environment is invalid.’
收藏回复举报
昇腾社区quadruped-robot 环境配置 安装 cupy失败,报错 ‘Your CUDA environment is invalid.’
t('forum.solved') 已解决
新人帖
发表于2024-10-24 18:17:17
0 查看

### 背景:
问题出在配置昇腾社区开源四足机器人的强化学习项目,项目网址:

https://gitee.com/HUAWEI-ASCEND/quadruped-robot/tree/master/rl-control/rl-robotics

配置的昇腾官网 Ubuntu 22.04镜像,使用系统自带的 conda 创建了 python 3.8 虚拟环境

虚拟环境信息如下:

  _libgcc_mutex      pkgs/main/linux-aarch64::_libgcc_mutex-0.1-main  

  _openmp_mutex      pkgs/main/linux-aarch64::_openmp_mutex-5.1-51_gnu  

  ca-certificates    pkgs/main/linux-aarch64::ca-certificates-2024.9.24-hd43f75c_0  

  ld_impl_linux-aar~ pkgs/main/linux-aarch64::ld_impl_linux-aarch64-2.40-h48e3ba3_0  

  libffi             pkgs/main/linux-aarch64::libffi-3.4.4-h419075a_1  

  libgcc-ng          pkgs/main/linux-aarch64::libgcc-ng-11.2.0-h1234567_1  

  libgomp            pkgs/main/linux-aarch64::libgomp-11.2.0-h1234567_1  

  libstdcxx-ng       pkgs/main/linux-aarch64::libstdcxx-ng-11.2.0-h1234567_1  

  ncurses            pkgs/main/linux-aarch64::ncurses-6.4-h419075a_0  

  openssl            pkgs/main/linux-aarch64::openssl-3.0.15-h998d150_0  

  pip                pkgs/main/linux-aarch64::pip-24.2-py38hd43f75c_0  

  python             pkgs/main/linux-aarch64::python-3.8.20-h4bb2201_0  

  readline           pkgs/main/linux-aarch64::readline-8.2-h998d150_0  

  setuptools         pkgs/main/linux-aarch64::setuptools-75.1.0-py38hd43f75c_0  

  sqlite             pkgs/main/linux-aarch64::sqlite-3.45.3-h998d150_0  

  tk                 pkgs/main/linux-aarch64::tk-8.6.14-h987d8db_0  

  wheel              pkgs/main/linux-aarch64::wheel-0.44.0-py38hd43f75c_0  

  xz                 pkgs/main/linux-aarch64::xz-5.4.6-h998d150_1  

  zlib               pkgs/main/linux-aarch64::zlib-1.2.13-h998d150_1  

在虚拟环境之中按照 README 文档配置时,

第二步 'install pytorch with cuda' 就有点小问题,文档内的指令:

pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio==0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

会报错没有对应版本,把三个库的+cu113 删掉之后就能下载了,只是目前还不知道能不能正常运行。
主要问题出在第四步:Install python dependencies with pip.

配置cupy报错信息如下:

Collecting cupy 

  Using cached cupy-12.3.0.tar.gz (1.8 MB) 

  Preparing metadata (setup.py) ... done 

Requirement already satisfied: numpy<1.29,>=1.20 in /home/HwHiAiUser/.conda/envs/PY38/lib/python3.8/site-packages (from cupy) (1.24.4) 

Collecting fastrlock>=0.5 (from cupy) 

  Using cached fastrlock-0.8.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl.metadata (9.3 kB) 

Using cached fastrlock-0.8.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl (51 kB) 

Building wheels for collected packages: cupy 

  Building wheel for cupy (setup.py) ... error 

  error: subprocess-exited-with-error 

   

  × python setup.py bdist_wheel did not run successfully. 

  │ exit code: 1 

  ╰─> [63 lines of output] 

      Clearing directory: /tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/cupy/.data 

       

      -------- Configuring Module: cuda -------- 

      cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ 

      /tmp/tmpqpb45gv3/a.cpp:1:10: fatal error: cublas_v2.h: No such file or directory 

          1 | #include <cublas_v2.h> 

            |          ^~~~~~~~~~~~~ 

      compilation terminated. 

      command '/usr/bin/g++' failed with exit code 1 

      cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ 

      /tmp/tmp48cod665/a.cpp:2:18: fatal error: cuda_runtime_api.h: No such file or directory 

          2 |         #include <cuda_runtime_api.h> 

            |                  ^~~~~~~~~~~~~~~~~~~~ 

      compilation terminated. 

      ************************************************** 

      *** WARNING: Cannot check compute capability 

      command '/usr/bin/g++' failed with exit code 1 

      ************************************************** 

       

      ************************************************************ 

      * CuPy Configuration Summary                               * 

      ************************************************************ 

       

      Build Environment: 

        Include directories: ['/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/cupy/_core/include/cupy/cub', '/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/cupy/_core/include'] 

        Library directories: [] 

        nvcc command       : (not found) 

        hipcc command      : (not found) 

       

      Environment Variables: 

        CFLAGS          : (none) 

        LDFLAGS         : (none) 

        LIBRARY_PATH    : (none) 

        CUDA_PATH       : (none) 

        NVCC            : (none) 

        HIPCC           : (none) 

        ROCM_HOME       : (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. 

       

      HINT: You are trying to build CuPy from source, which is NOT recommended for general use. 

            Please consider using binary packages instead. 

       

      Please refer to the Installation Guide for details: 

      https://docs.cupy.dev/en/stable/install.html 

       

      ************************************************************ 

       

      Traceback (most recent call last): 

        File "<string>", line 2, in <module> 

        File "<pip-setuptools-caller>", line 34, in <module> 

        File "/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/setup.py", line 88, in <module> 

          ext_modules = cupy_setup_build.get_ext_modules(True, ctx) 

        File "/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/install/cupy_builder/cupy_setup_build.py", line 449, in get_ext_modules 

          extensions = make_extensions(ctx, compiler, use_cython) 

        File "/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/install/cupy_builder/cupy_setup_build.py", line 305, in make_extensions 

          raise Exception('Your CUDA environment is invalid. ' 

      Exception: Your CUDA environment is invalid. Please check above error log. 

      [end of output] 

   

  note: This error originates from a subprocess, and is likely not a problem with pip. 

  ERROR: Failed building wheel for cupy 

  Running setup.py clean for cupy                                                                         

  error: subprocess-exited-with-error 

   

  × python setup.py clean did not run successfully. 

  │ exit code: 1 

  ╰─> [63 lines of output] 

      Clearing directory: /tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/cupy/.data 

       

      -------- Configuring Module: cuda -------- 

      cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ 

      /tmp/tmpao8gek5d/a.cpp:1:10: fatal error: cublas_v2.h: No such file or directory 

          1 | #include <cublas_v2.h> 

            |          ^~~~~~~~~~~~~ 

      compilation terminated. 

      command '/usr/bin/g++' failed with exit code 1 

      cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ 

      /tmp/tmpmcnibi5p/a.cpp:2:18: fatal error: cuda_runtime_api.h: No such file or directory 

          2 |         #include <cuda_runtime_api.h> 

            |                  ^~~~~~~~~~~~~~~~~~~~ 

      compilation terminated. 

      ************************************************** 

      *** WARNING: Cannot check compute capability 

      command '/usr/bin/g++' failed with exit code 1 

      ************************************************** 

       

      ************************************************************ 

      * CuPy Configuration Summary                               * 

      ************************************************************ 

       

      Build Environment: 

        Include directories: ['/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/cupy/_core/include/cupy/cub', '/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/cupy/_core/include'] 

        Library directories: [] 

        nvcc command       : (not found) 

        hipcc command      : (not found) 

       

      Environment Variables: 

        CFLAGS          : (none) 

        LDFLAGS         : (none) 

        LIBRARY_PATH    : (none) 

        CUDA_PATH       : (none) 

        NVCC            : (none) 

        HIPCC           : (none) 

        ROCM_HOME       : (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. 

       

      HINT: You are trying to build CuPy from source, which is NOT recommended for general use. 

            Please consider using binary packages instead. 

       

      Please refer to the Installation Guide for details: 

      https://docs.cupy.dev/en/stable/install.html 

       

      ************************************************************ 

       

      Traceback (most recent call last): 

        File "<string>", line 2, in <module> 

        File "<pip-setuptools-caller>", line 34, in <module> 

        File "/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/setup.py", line 88, in <module> 

          ext_modules = cupy_setup_build.get_ext_modules(True, ctx) 

        File "/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/install/cupy_builder/cupy_setup_build.py", line 449, in get_ext_modules 

          extensions = make_extensions(ctx, compiler, use_cython) 

        File "/tmp/pip-install-fgb5xcjm/cupy_a4dfe9a4d70a484cb82b1cddb81c22ee/install/cupy_builder/cupy_setup_build.py", line 305, in make_extensions 

          raise Exception('Your CUDA environment is invalid. ' 

      Exception: Your CUDA environment is invalid. Please check above error log. 

      [end of output] 

   

  note: This error originates from a subprocess, and is likely not a problem with pip. 

  ERROR: Failed cleaning build dir for cupy 

Failed to build cupy                                                                                      

ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (cupy) 

我要发帖子