【发布时间】:2021-12-20 14:33:27
【问题描述】:
我有一个包含非常特定的包版本和较旧版本的 Python 的 Conda 环境。我的本地系统对于我的机器学习代码来说有点太慢了,我希望在 Colab 或 Paperspace Gradient 上使用这个环境。
如何在这些平台之一上运行我的 Conda 环境?
【问题讨论】:
标签: jupyter-notebook anaconda conda google-colaboratory
我有一个包含非常特定的包版本和较旧版本的 Python 的 Conda 环境。我的本地系统对于我的机器学习代码来说有点太慢了,我希望在 Colab 或 Paperspace Gradient 上使用这个环境。
如何在这些平台之一上运行我的 Conda 环境?
【问题讨论】:
标签: jupyter-notebook anaconda conda google-colaboratory
您可以使用MiniConda 来处理您的情况。 Colab 中的设置如下:
!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!chmod +x Miniconda3-latest-Linux-x86_64.sh
!./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local
!conda --version # conda 4.10.3
最后一个命令应该为当前版本打印conda 4.10.3。更新到最新版本后:
!conda update --channel defaults --all --yes
【讨论】:
不能简单地使用任意环境。您必须将环境中的 Python 版本与 Colab 运行的版本(当前为 v3.7)相匹配,然后在模块搜索路径中包含环境的 lib/python3.7/site-packages,例如
import sys
sys.path.append('/path/to/envs/lib/python3.7/site-packages/')
【讨论】: