如何在 Google Colab 上安装 nvidia apex
How to install nvidia apex on Google Colab
我所做的就是按照官方 github 网站上的说明进行操作
!git clone https://github.com/NVIDIA/apex
!cd apex
!pip install -v --no-cache-dir ./
它给我错误:
ERROR: Directory './' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
Exception information:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 178, in main
status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py", line 326, in run
self.name, wheel_cache
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 268, in populate_requirement_set
wheel_cache=wheel_cache
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/req/constructors.py", line 248, in install_req_from_line
"nor 'pyproject.toml' found." % name
pip._internal.exceptions.InstallationError: Directory './' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
已更新
首先,创建一个文件,例如setup.sh
如下:
对于具有 CUDA 和 C++ 扩展的顶点:
%%writefile setup.sh
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
然后,安装它
!sh setup.sh
对于 Python-仅构建
%%writefile setup.sh
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir ./
A Python-only 构建省略了使用 apex.optimizers.FusedAdam
、apex.normalization.FusedLayerNorm
等所需的某些 Fused 内核
(只想添加评论,但我没有足够的声誉...)
它对我有用,但实际上不需要 cd
。另外,我需要这里建议的两个全局选项:https://github.com/NVIDIA/apex/issues/86
%%writefile setup.sh
git clone https://github.com/NVIDIA/apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./apex
然后
!sh setup.sh
添加 CUDA_HOME 环境变量后为我工作:
%%writefile setup.sh
export CUDA_HOME=/usr/local/cuda-10.1
git clone https://github.com/NVIDIA/apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./apex
!sh setup.sh
在 colab 中而不是使用“!”在 cd
命令
之前使用“%”
!git clone https://github.com/NVIDIA/apex
%cd apex
!pip install -v --no-cache-dir ./
上面的代码可以正常工作。
问题出在 !cd apex
。请改用 %cd apex
。
读这个:
我尝试了几个选项,但我喜欢 this website 中的那个,它与 fast_bert 和 torch 配合使用非常好:
try:
import apex
except Exception:
! git clone https://github.com/NVIDIA/apex.git
% cd apex
!pip install --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" .
%cd ..
我使用 paperspace,这对我有用:
!pip install git+https://github.com/NVIDIA/apex
我所做的就是按照官方 github 网站上的说明进行操作
!git clone https://github.com/NVIDIA/apex
!cd apex
!pip install -v --no-cache-dir ./
它给我错误:
ERROR: Directory './' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
Exception information:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 178, in main
status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py", line 326, in run
self.name, wheel_cache
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 268, in populate_requirement_set
wheel_cache=wheel_cache
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/req/constructors.py", line 248, in install_req_from_line
"nor 'pyproject.toml' found." % name
pip._internal.exceptions.InstallationError: Directory './' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
已更新
首先,创建一个文件,例如setup.sh
如下:
对于具有 CUDA 和 C++ 扩展的顶点:
%%writefile setup.sh
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
然后,安装它
!sh setup.sh
对于 Python-仅构建
%%writefile setup.sh
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir ./
A Python-only 构建省略了使用 apex.optimizers.FusedAdam
、apex.normalization.FusedLayerNorm
等所需的某些 Fused 内核
(只想添加评论,但我没有足够的声誉...)
它对我有用,但实际上不需要 cd
。另外,我需要这里建议的两个全局选项:https://github.com/NVIDIA/apex/issues/86
%%writefile setup.sh
git clone https://github.com/NVIDIA/apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./apex
然后
!sh setup.sh
添加 CUDA_HOME 环境变量后为我工作:
%%writefile setup.sh
export CUDA_HOME=/usr/local/cuda-10.1
git clone https://github.com/NVIDIA/apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./apex
!sh setup.sh
在 colab 中而不是使用“!”在 cd
命令
!git clone https://github.com/NVIDIA/apex
%cd apex
!pip install -v --no-cache-dir ./
上面的代码可以正常工作。
问题出在 !cd apex
。请改用 %cd apex
。
读这个:
我尝试了几个选项,但我喜欢 this website 中的那个,它与 fast_bert 和 torch 配合使用非常好:
try:
import apex
except Exception:
! git clone https://github.com/NVIDIA/apex.git
% cd apex
!pip install --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" .
%cd ..
我使用 paperspace,这对我有用:
!pip install git+https://github.com/NVIDIA/apex