google-cloud-platform - 将 Caffe 添加到 Datalab 实例
问题描述
我正在尝试运行使用 Caffe 的 Jupyter 笔记本。Caffe 不包含在 datalab 中。我正在尝试从 Jupyter 笔记本中安装该库(如 datalab 文档中所建议的那样),但遇到了问题。
我是datalab的新手,一般都是新手。任何建议将不胜感激。
datalab 文档建议 了3 种策略 来添加尚未包含的 python 库。我专注于这些策略中的前两个。
我的数据云实例的平台是:
platform.platform() 'Linux-4.4.111+-x86_64-with-debian-stretch-sid'
下面我将列出我尝试过的各种事情以及我收到的错误消息。对于第一个策略,我在同一个笔记本的一个单元格中尝试了这些东西。
(尝试1)
!pip install caffe
#results in the error:
#Collecting caffe
# Could not find a version that satisfies the requirement caffe (from
#versions: )
#No matching distribution found for caffe
!pip install caffe-cpu
#results in the same error as above
我从研究中意识到 caffe 不能用 pip 安装,所以我尝试了:
(尝试 2)
!apt-get install caffe
#results in the error:
#Reading package lists... Done
#Building dependency tree
#Reading state information... Done
#E: Unable to locate package caffe
!apt-get install caffe-cpu
#results in the same error as above
基于另一个stackoverflow question,我为 caffe 和 caffe-cpu 尝试了以下内容:
(尝试 3)
%bash
echo 'Y' | apt-get update
echo 'Y' | apt-get install caffe-cpu
#This results in output with a lot of warnings, but ends with the error:
#E: Unable to locate package caffe-cpu
#Stack Overflow prevented me from posting the entire thing, thinking it was spam
(尝试4)
根据文档中推荐的第二种策略,我尝试在单独的笔记本中运行此代码:
%%bash
echo "pip install caffe" >> /content/datalab/.config/startup.sh
cat /content/datalab/.config/startup.sh
#This resulted in the error:
#bash: /usr/local/lib/libtinfo.so.5: no version information available (required by bash)
我跑的时候得到了同样的结果:
%%bash
echo "apt-get install caffe" >> /content/datalab/.config/startup.sh
cat /content/datalab/.config/startup.sh
解决方案
我最终尝试安装 caffe-cpu,但/etc/apt/sources.list
在 datalab 实例中,该文件似乎没有安装它所需的存储库。为了解决这个问题,我在创建的笔记本中使用了以下命令:
!echo "deb http://deb.debian.org/debian stretch main\n\
deb-src http://deb.debian.org/debian stretch main\n\
deb http://deb.debian.org/debian-security/ stretch/updates main\n\
deb-src http://deb.debian.org/debian-security/ stretch/updates main\n\
deb http://deb.debian.org/debian stretch-updates main\n\
deb-src http://deb.debian.org/debian stretch-updates main" >> /etc/apt/sources.list
这将添加debian/stretch
包含 caffe-cpu 包的必要存储库。
注意:奇怪的是,为了正确读取换行符,我不需要将-e
标志添加到命令中,您可以通过执行来检查文件是否已正确更新。echo
!cat /etc/apt/sources.list
完成后,运行以下命令:
!apt-get update && apt-get install caffe-cpu -y --allow-unauthenticated
命令完成后,caffe-cpu 包将安装在您的 VM 中。
推荐阅读
- python - 如何从字符串列表中删除引号并将其再次存储为列表..?
- node.js - 将循环字符串转换为 json
- android - 拍摄水平滚动图形视图的屏幕截图
- html - 如何删除视频周围的空白并将其拉伸以填充整个内容?
- react-native - 如何使用 react-native-mapbox-gl 在 react-native 中查找具有格式化地址的最近地点
- ios - 虚拟键盘在 iOS React Native 上不可见
- android - 在另一个活动中调用函数
- javascript - 在 javascript 中使用 == 总是错误的
- selenium - selenium python:驱动程序没有 find_element_by 属性
- powerbi - 是否有任何选项/函数/api 来获取 Power BI 报告中使用的字段(表名和列)?