我所做的就是按照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.
答案 0 :(得分:5)
首先,创建一个文件,例如setup.sh
如下:
%%writefile setup.sh
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir ./
然后安装
!sh setup.sh
答案 1 :(得分:2)
(只想添加评论,但我没有足够的声誉...)
它对我有用,但是实际上不需要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
答案 2 :(得分:2)
在colab中而不是使用“!”在cd
命令前使用“%”
!git clone https://github.com/NVIDIA/apex
%cd apex
!pip install -v --no-cache-dir ./
上面的代码可以正常工作。
答案 3 :(得分:1)
我尝试了几种选择,但是我喜欢this website中的一种,它与fast_bert和火炬配合得很好:
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 ..
答案 4 :(得分:0)
添加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
答案 5 :(得分:0)
问题出在!cd apex
上。请改用%cd apex
。
答案 6 :(得分:0)
我使用纸张空间,这对我有用:
!pip install git+https://github.com/NVIDIA/apex