[LINUX] Creating a graphtool Python environment, installing packages, and using the environment on IPEA's Linux SBSB server - jamiefogel/Networks GitHub Wiki

INSTALLATION OF MINICONDA

  • Log into the linux server
  • Go to root with sudo privileges

sudo su

  • Enable proxy connection (temporarily)

export http_proxy="http://cache.ipea.gov.br:3128/"

export https_proxy="http://cache.ipea.gov.br:3128/"

  • Or enable proxy connection (permanently) by adding the two lines above to the ~/.bashrc by doing

nano ~/.bashrc (paste the two lines at the end of the file, CRTL+O to save it, enter, and CRTL+X to exit)

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

  • Run the bash file

bash Miniconda3-latest-Linux-x86_64.sh

  • When asked for where to install it, install it somewhere in the user file system, e.g.

/home/DLIPEA/p13861161/miniconda3

  • After installed, re-initiate the terminal with

source ~/.bashrc

  • Run

conda init

CREATING A GRAPHTOOL ENVIRONMENT

  • After steps above, still as a sudo user, run

conda create --name labor_gt -c conda-forge graph-tool

  • Give user permissions to the new folder

sudo chown -R p13861161: /home/DLIPEA/p13861161/miniconda3

  • In order to make conda accessible to our user, we need to return to the user profile

su p13861161

  • Add the miniconda to the path, so we can execute the function conda from our user

echo 'export PATH="/home/DLIPEA/p13861161/miniconda3/bin:$PATH"' >> ~/.bashrc

  • Test the function conda with

conda init

conda --version

INSTALLING PACKAGES

  • First we want to make sure we are using the internet proxy by running

export http_proxy="http://cache.ipea.gov.br:3128/"

export https_proxy="http://cache.ipea.gov.br:3128/"

  • Or enable proxy connection (permanently) by adding the two lines above to the ~/.bashrc by doing

nano ~/.bashrc (paste the two lines at the end of the file, CRTL+O to save it, enter, and CRTL+X to exit)

  • Enter in our environment

conda activate labor_gt

  • Install any package with pip3, e.g.:

pip3 install pyarrow

  • Notice that installing pytorch is less trivial, as we need to specify GPU options

(labor_gt) p13861161@graphtool-prod:~$ nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2017 NVIDIA Corporation

Built on Fri_Nov__3_21:07:56_CDT_2017

Cuda compilation tools, release 9.1, V9.1.85

  • Install torch

conda install pytorch torchvision torchaudio cudatoolkit=9.2 -c pytorch

UTILIZING THE NEW PYTHON AND NEW ENVIRONMENT

  • After logging in at our regular user in linux, enter in our environment

conda activate labor_gt

  • Run python

python