Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I install Torch on Google Colab if it does not exist the file ~/.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

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: No such file or directory

I also use this command to find bashrc

!find / -name '*bashrc'

And here is the output I get

/root/.bashrc

/etc/skel/.bashrc

/etc/bash.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/bash.bashrc

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.

EDIT: I'm not sure if Torch is installed or not. The specific problem here is that I just get an error

command not found

whenever I run th or luarocks

like image 644
hungvo Avatar asked Oct 17 '22 16:10

hungvo


1 Answers

in case this question is still actual, type these commands in Google Colab:`

from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())

accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'

!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision
import torch
like image 192
Milica Avatar answered Oct 20 '22 09:10

Milica