jupyter notebook
https://jupyter-notebook.readthedocs.io/en/stable/config_overview.html
By changing the config file: ~/.jupyter/jupyter_notebook_config.py
# The convention in KnowComp
c.NotebookApp.open_browser = False
c.NotebookApp.base_url = '/notebook/xxxx' # xxxx is your account
from notebook.auth import passwd
c.NotebookApp.passwd = passwd('yyyy') # yyyy is the password you defined
c.NotebookApp.port = 1zzzz # zzzz is your UID
c.allow_remote_access = True
c.NotebookApp.allow_origin = ‘*’ # allow all origins
c.NotebookApp.ip = ‘0.0.0.0’ # listen on all IPs
# open in browser: <http://songcpu1.cse.ust.hk/notebook/xxxx>
By adding arguments
jupyter lab --ip=0.0.0.0 --allow-root --no-browser --NotebookApp.token="" --notebook-dir=/ --NotebookApp.allow_origin="*" --port=8888
# listen on all IPs, all all origins (otherwise local machine only)
# Zory-2022
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# colab mounting
from google.colab import drive
drive.mount('/content/drive')
%cd '/content/drive/Othercomputers/My MacBook Pro/COMP4471/assignment1'
%pwd
%ls
!wget --user=username --ask-password <https://course.cse.ust.hk/comp2211/assignments/pa1/data/20ng_test_labels.npy>
# easier to print by putting variable as a single line
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
# make matplotlib figures appear inline in the notebook rather than in a new window.
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# <http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython>
%load_ext autoreload
%autoreload 2
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
pd.set_option('display.max_colwidth', None)
%%timeit
ans = fixed_model(x_var)
%%timeit
torch.cuda.synchronize() # Make sure there are no pending GPU computations
ans = fixed_model_gpu(x_var_gpu) # Feed it through the model!
torch.cuda.synchronize() # Make sure there are no pending GPU computations