如果文件 ~/.bashrc 不存在,我如何在 Google Colab 上安装 Torch? [英] How could I install Torch on Google Colab if it does not exist the file ~/.bashrc?

查看:104
本文介绍了如果文件 ~/.bashrc 不存在,我如何在 Google Colab 上安装 Torch?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安装 Torch (http://torch.ch/docs/getting-started.html#_) 在 Google Colab 上.但是,要安装 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: line 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

未找到命令

每当我运行 thluarocks

推荐答案

我通过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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆