python - 如何在 Google colab 上永久安装 Rapids?
问题描述
有没有办法在 Google colab 上永久安装 Rapids?我尝试了 StackOverflow 和其他网站上给出的许多解决方案,但没有任何效果。这是一个非常大的库,每次我想在 colab 上工作时都下载它非常令人沮丧。
我从 Rapids 尝试了这段代码,但它也不起作用。当我关闭 colab 并稍后重新开始时,我得到ModuleNotFoundError: No module named 'cudf'.
# Install RAPIDS
!git clone https://github.com/rapidsai/rapidsai-csp-utils.git
!bash rapidsai-csp-utils/colab/rapids-colab.sh stable
import sys, os, shutil
sys.path.append('/usr/local/lib/python3.7/site-packages/')
os.environ['NUMBAPRO_NVVM'] = '/usr/local/cuda/nvvm/lib64/libnvvm.so'
os.environ['NUMBAPRO_LIBDEVICE'] = '/usr/local/cuda/nvvm/libdevice/'
os.environ["CONDA_PREFIX"] = "/usr/local"
for so in ['cudf', 'rmm', 'nccl', 'cuml', 'cugraph', 'xgboost', 'cuspatial']:
fn = 'lib'+so+'.so'
source_fn = '/usr/local/lib/'+fn
dest_fn = '/usr/lib/'+fn
if os.path.exists(source_fn):
print(f'Copying {source_fn} to {dest_fn}')
shutil.copyfile(source_fn, dest_fn)
# fix for BlazingSQL import issue
# ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/python3.7/site-packages/../../libblazingsql-engine.so)
if not os.path.exists('/usr/lib64'):
os.makedirs('/usr/lib64')
for so_file in os.listdir('/usr/local/lib'):
if 'libstdc' in so_file:
shutil.copyfile('/usr/local/lib/'+so_file, '/usr/lib64/'+so_file)
shutil.copyfile('/usr/local/lib/'+so_file, '/usr/lib/x86_64-linux-gnu/'+so_file)
提出了一个解决方案,但它使用 pip 安装库 -如何在 Colab 中永久安装库?但是不能使用 pip 安装 Rapids。它只能使用 Conda 安装。这是安装它的代码。
conda create -n rapids-0.19 -c rapidsai -c nvidia -c conda-forge \
rapids-blazing=0.19 python=3.7 cudatoolkit=11.0
我尝试nb_path
使用上述链接所建议的 --prefix 标志将谷歌驱动器路径()包含到此代码中,!pip install --target=$nb_path jdc
但我得到了一个syntax error
.
谁能告诉我如何将此 nb_path 设置为conda create
上面的代码?
解决方案
作为参考,RAPIDS 安装的 conda 目标路径是/usr/local
. 我们在 RAPIDS-Colab 安装脚本中使用不同的位置来使其工作。
目前,我不知道有任何方法可以让用户将 RAPIDS 永久安装到 Google Colab 中。Google Colab 的设计目的不是为了保存未预装在环境中的库(或与此相关的任何数据)。虽然你有一个看起来不错的解决方法来安装谷歌驱动器的 pip 库和数据集,但使用 RAPIDS,它有点棘手,因为我们更新了相当多的 Colab 环境,以便让它甚至安装 RAPIDS。你提出的是一条有趣的探索之路。我们鼓励并与我们的 Slack 频道中的 RAPIDS 社区成员合作,他们尝试新方法并改进我们的一些社区代码,例如RAPIDS-Colab 安装脚本。
请记住,RAPIDS + Google Colab 的努力绝不仅仅是一种“尝试 RAPIDS”的有趣、简单的方式。对于 Google Cloud 用户,GCP 应该是下一步。虽然看到使用量随着时间的推移而增长令人振奋,但 Google 需要创建一个预先安装了 RAPIDS 的 Colab 实例,以实现您想要发生的事情。你应该让知道你想要这个
- 打开任何 Colab 笔记本
- 转到“帮助”菜单并选择“发送反馈...”</li>
同时,如果您需要一个现成的实例,有一些廉价的、支持 RAPIDS 的快速启动选项即将出现。
推荐阅读
- ios - 无法使用 iOS Beta App 连接到后端
- csv - 如何在 csv 文件中转换从 TCP/IP 接收到的数据?
- algorithm - 多渠道联系人问题:根据信息查找相关工单
- java - 即使使用 CascadeType.All,对象也会引用未保存的瞬态
- python - Numpy:沿特定轴的外部总和
- json - 从链接服务器 openquery 检索 SQL Server 中的一些 JSON 数据
- python - 如何从逗号(,)或换行符中拆分字符串
- sql - 根据三个单独表中的数据更新字段值
- android - 如何滚动到 AlertDialog 中的特定列表位置
- react-native - 如何从 React Native 中的多个 fireStore 集合中获取数据?