项目环境搭建
查看当前gpu
!nvidia-smi
下载conda
!which python ##查看python的绝对路径
!python --version ##查看python版本号
!echo $PYTHONPATH ##检查PYTHONPATH变量并置为空
%env PYTHONPATH=
!echo $PYTHONPATH ##检查PYTHONPATH
%%bash
MINICONDA_INSTALLER_SCRIPT=Miniconda3-latest-Linux-x86_64.sh
MINICONDA_PREFIX=/usr/local
wget https://repo.continuum.io/miniconda/$MINICONDA_INSTALLER_SCRIPT
chmod +x $MINICONDA_INSTALLER_SCRIPT
./$MINICONDA_INSTALLER_SCRIPT -b -f -p $MINICONDA_PREFIX
##!wget -c https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh ##安装支持python3.7的conda
查看conda是否安装成功
参考https://www.cnblogs.com/liulunyang/p/14291526.html
https://www.jianshu.com/p/edaa744ea47d
https://www.codenong.com/cs109703751/
!which conda
!conda --version
!which python
!python
import sys
sys.path
import sys
_ = (sys.path
.append("/usr/local/lib/python3.9/site-packages"))
import sys
sys.path
用conda创建一个新环境
# 创建一个环境名为py34,指定Python版本是3.4
#(不用管是3.4.x,conda会为我们自动寻找3.4.x中的最新版本)
conda create --name py36 python=3.6
# 通过创建环境,我们可以使用不同版本的Python
conda create --name py27 python=2.7
# 在Linux & Mac中使用source activate激活
source activate py34
# 在Linux & Mac中使用source deactivate
source deactivate
命令激活失败
注意只有把conda info -e放在一个shell中才成立,否则会回到默认环境中
参考链接:
https://stackoverflow.com/questions/62610289/conda-activate-and-conda-init-fail-to-work-in-colab-as-per-june-2020
https://stackoverflow.com/questions/55342122/conda-activate-on-travis-ci
```
%%shell
eval "$(conda shell.bash hook)"
conda activate py36
python --version
conda info -e
# 删除环境
conda remove -n py34 --all
#查看当前所有环境
输出中带有【*】号的的就是当前所处的环境
conda info -e
当!cd /root/miniconda3/bin/切换目录不起效时,可以使用
!cd是临时起效,%cd是永久起效
%cd /root/miniconda3/bin/
在colab中切换工作目录
%cd /content/drive/MyDrive/dachuang/example
拷贝github上的nv-wavenet项目
!git clone https://github.com/NVIDIA/nv-wavenet.git nv_wavenet
nv-wavenet报错
Successfully installed absl-py-1.0.0 appdirs-1.4.4 audioread-2.1.9 cffi-1.15.0 charset-normalizer-2.0.10 cycler-0.11.0 decorator-5.1.1 deepspeech-0.8.2 idna-3.3 jiwer-2.3.0 joblib-1.1.0 kiwisolver-1.3.1 librosa-0.8.1 llvmlite-0.36.0 matplotlib-3.3.4 numba-0.53.1 packaging-21.3 pillow-8.4.0 pooch-1.5.2 pycparser-2.21 pyparsing-3.0.6 python-Levenshtein-0.12.2 python-dateutil-2.8.2 requests-2.27.1 resampy-0.2.2 scikit-learn-0.24.2 scipy-1.5.4 soundfile-0.10.3.post1 threadpoolctl-3.0.0 unidecode-1.3.2 urllib3-1.26.8
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
nvcc -arch=sm_70 -std=c++11 --use_fast_math -lineinfo -maxrregcount 128 -I .. wavenet_infer.cu ../matrix.cpp -lz -Xcompiler -fPIC -shared -o libwavenet_infer.so
../nv_wavenet_conversions.cuh(41): error: class "cudaPointerAttributes" has no member "memoryType"
1 error detected in the compilation of "wavenet_infer.cu".
Makefile:48: recipe for target 'wavenet_infer' failed
make: *** [wavenet_infer] Error 1
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda10.1'
running install
running bdist_egg
running egg_info
writing nv_wavenet_ext.egg-info/PKG-INFO
writing dependency_links to nv_wavenet_ext.egg-info/dependency_links.txt
writing top-level names to nv_wavenet_ext.egg-info/top_level.txt
/usr/local/envs/py36/lib/python3.6/site-packages/torch/utils/cpp_extension.py:381: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
warnings.warn(msg.format('we could not find ninja.'))
reading manifest file 'nv_wavenet_ext.egg-info/SOURCES.txt'
writing manifest file 'nv_wavenet_ext.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building 'nv_wavenet_ext' extension
gcc -pthread -B /usr/local/envs/py36/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/content/drive/MyDrive/dachuang/example/nv_wavenet/pytorch -I/usr/local/envs/py36/lib/python3.6/site-packages/torch/include -I/usr/local/envs/py36/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/usr/local/envs/py36/lib/python3.6/site-packages/torch/include/TH -I/usr/local/envs/py36/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda10.1/include -I/usr/local/envs/py36/include/python3.6m -c wavenet_infer_wrapper.cpp -o build/temp.linux-x86_64-3.6/wavenet_infer_wrapper.o -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -DTORCH_EXTENSION_NAME=nv_wavenet_ext -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
wavenet_infer_wrapper.cpp:28:10: fatal error: THC/THC.h: No such file or directory
#include <THC/THC.h>
^~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
<ipython-input-113-a9f6bcd2571d> in <module>()
----> 1 get_ipython().run_cell_magic('shell', '', 'eval "$(conda shell.bash hook)" \nconda activate py36\npython --version\nconda info -e\n\nconda list\nconda install cudatoolkit=10.1\nconda install pytorch -c pytorch\nconda install libsndfile=1.0.28 -c conda-forge\nconda install numpy\npip install absl-py librosa soundfile matplotlib scipy scikit-learn numba jiwer unidecode deepspeech==0.8.2\nexport FORCE_CUDA="1"\nexport CUDA_HOME=/usr/local/cuda10.1\ncd /content/drive/MyDrive/dachuang/example/nv_wavenet/pytorch/\nmake\npython build.py install')
2 frames
/usr/local/lib/python3.7/dist-packages/google/colab/_system_commands.py in check_returncode(self)
137 if self.returncode:
138 raise subprocess.CalledProcessError(
--> 139 returncode=self.returncode, cmd=self.args, output=self.output)
140
141 def _repr_pretty_(self, p, cycle): # pylint:disable=unused-argument
CalledProcessError: Command 'eval "$(conda shell.bash hook)"
conda activate py36
python --version
conda info -e
conda list
conda install cudatoolkit=10.1
conda install pytorch -c pytorch
conda install libsndfile=1.0.28 -c conda-forge
conda install numpy
pip install absl-py librosa soundfile matplotlib scipy scikit-learn numba jiwer unidecode deepspeech==0.8.2
export FORCE_CUDA="1"
export CUDA_HOME=/usr/local/cuda10.1
cd /content/drive/MyDrive/dachuang/example/nv_wavenet/pytorch/
make
python build.py install' returned non-zero exit status 1.
一篇博客说https://github.com/NVIDIA/nv-wavenet/issues/102
所以
return (attr.type == cudaMemoryTypeDevice);
colab的运行超时了,晚点再试试,先歇息诶,起来继续debug
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)