代码如下:
import subprocess
command="apt install -y git"
res = subprocess.call(command, shell=True)
command='''git clone https://github.com/NVIDIA/apex && cd apex && pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./'''
res = subprocess.call(command, shell=True)
print('res:', res)
import apex
print(dir(apex))
需要耗时20分钟
最后输出结果是:
dir(apex)=['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']