如果〜/ .bashrc文件不存在,该如何在Google Colab上安装Torch? [英] How could I install Torch on Google Colab if it does not exist the file ~/.bashrc?
问题描述
我想安装Torch( http://torch.ch/docs/getting -started.html#_ )。但是,要安装Torch,我们需要在最后一步中运行以下命令 source〜/ .bashrc
I want to install Torch (http://torch.ch/docs/getting-started.html#_) on Google Colab. However, to install Torch, we need to run the following command at the final step source ~/.bashrc
要运行此命令在Google colab上,我使用的代码是
To run this command on google colab, the code I use is
%%bash
source ~/.bashrc
运行这些命令时,会收到警告
When I run those, I get a warning
bash:第1行:/ content /.bashrc:没有这样的文件或目录
bash: line 1: /content/.bashrc: No such file or directory
我也使用此命令查找bashrc
I also use this command to find bashrc
!find / -name '*bashrc'
这是我得到的输出
/root/.bashrc
/root/.bashrc
/etc/skel/.bashrc
/etc/skel/.bashrc
/ etc / bash.bashrc
/etc/bash.bashrc
/usr/share/base-files/dot.bashrc
/usr/share/base-files/dot.bashrc
/ usr / share / doc / adduser / examples / adduser.local.conf.examples / skel / dot.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
我尝试在所有这些路径上运行 source
命令。我也尝试使用 .profile
进行相同操作。但是尚未安装Torch。
I try to run the source
command on all of those paths. I also try the same with .profile
. But the Torch still has not been installed.
编辑:我不确定是否已安装Torch。这里的具体问题是我只是得到一个错误
I'm not sure if Torch is installed or not. The specific problem here is that I just get an error
找不到命令
command not found
每当我运行 th
或 luarocks
推荐答案
我通过python设置了所需的路径和环境
I set the required path and environment by python
#for Torch with Lua 5.3:
import os
os.environ['LUA_PATH'] = '/root/.luarocks/share/lua/5.3/?.lua;/root/.luarocks/share/lua/5.3/?/init.lua;/root/torch/install/share/lua/5.3/?.lua;/root/torch/install/share/lua/5.3/?/init.lua;/root/torch/install/lib/lua/5.3/?.lua;/root/torch/install/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua'
os.environ['LUA_CPATH'] ='/root/.luarocks/lib/lua/5.3/?.so;/root/torch/install/lib/lua/5.3/?.so;/root/torch/install/lib/lua/5.3/loadall.so;./?.so'
os.environ['PATH'] += ':/root/torch/install/bin'
if 'LD_LIBRARY_PATH' not in os.environ.keys():
os.environ['LD_LIBRARY_PATH'] = ''
else:
os.environ['LD_LIBRARY_PATH'] += ':'
os.environ['LD_LIBRARY_PATH'] +='/root/torch/install/lib'
if 'DYLD_LIBRARY_PATH' not in os.environ.keys():
os.environ['DYLD_LIBRARY_PATH'] = ''
else:
os.environ['DYLD_LIBRARY_PATH'] += ':'
os.environ['DYLD_LIBRARY_PATH'] +='/root/torch/install/lib'
if 'LUA_CPATH' not in os.environ.keys():
os.environ['LUA_CPATH'] = ''
else:
os.environ['LUA_CPATH'] += ';'
os.environ['LUA_CPATH'] += '/root/torch/install/lib/?.so'
这篇关于如果〜/ .bashrc文件不存在,该如何在Google Colab上安装Torch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!