Skip to content

Instantly share code, notes, and snippets.

@prateekrajgautam
Last active February 26, 2024 11:38
Show Gist options
  • Save prateekrajgautam/12e391148394b59869b57c3d078e2a62 to your computer and use it in GitHub Desktop.
Save prateekrajgautam/12e391148394b59869b57c3d078e2a62 to your computer and use it in GitHub Desktop.
How to use jupyterlab on CAS server instead of googlecolab

First login to server

  • Linux users: Use any linux terminal
  • Windows users: install mobaterm
ssh -X -L 8888:127.0.0.1:8888 username@10.135.27.6

Second Create a shell.nix file with following content

This step is require only once

{ pkgs ? import (fetchTarball  "https://github.com/NixOS/nixpkgs/tarball/nixos-22.11") {} }:
let
  message = "Lets Start Development";
in 
pkgs.mkShellNoCC {
  buildInputs = with pkgs; [ cowsay python3 python3Packages.pip pipenv];

  packages = with pkgs; [
    (python3.withPackages (ps: [ps.numpy ps.matplotlib ps.tensorflow ps.jupyterlab ps.pandas]))
    vim 
    curl     
    vscodium 
    firefox
    cinnamon.nemo
  ];

  shellHook = ''
    cowsay ${message}
    nemo . & codium . & jupyter-lab
  '';
}

Third execute command

# make sure shell.nix is in the current directory
nix-shell

How to use jupyterlab on CAS server instead of googlecolab

  • Linux users: Use any linux terminal
  • Windows users: install mobaterm

ssh login to server with your login credentials

you need an account on server created by administrator
#username
#password

# SSH
ssh -X username@10.135.27.6
# enter your passowrd, when you type nothing is visible but it is accepting keys

#you can also try port forwarding
ssh -X -L 8888:127.0.0.1:8888 username@10.135.27.6


Now install and execute jupyterlab

# test command 1
nix-shell -p firefox --run firefox
# test command 2
nix-shell -p firefox python3 python3Packages.pip python3Packages.jupyterlab --run jupyter-lab

# Command with important packages pre installed
nix-shell -p git firefox python3 python3Packages.pip python3Packages.numpy python3Packages.pandas python3Packages.matplotlib python3Packages.jupyterlab --run jupyter-lab

# with pytorch
export NIXPKGS_ALLOW_UNFREE=1
nix-shell -p git firefox python3 python3Packages.pip python311Packages.torchvision-bin python3Packages.numpy python3Packages.pandas python3Packages.matplotlib python3Packages.jupyterlab --run jupyter-lab



# some problem with tensorflow
export NIXPKGS_ALLOW_UNFREE=1
nix-shell -p git firefox python3 python3Packages.pip python3Packages.tensorflow python310Packages.keras python3Packages.numpy python3Packages.pandas python3Packages.matplotlib python3Packages.jupyterlab --run jupyter-lab

Try vscode

export NIXPKGS_ALLOW_UNFREE=1
nix-shell -p vscode --run "code ."

Try firefox

nix-shell -p firefox --run firefox

Try vscodium

nix-shell -p vscodium --run "codium ."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment