jupyter profiling https://jakevdp.github.io/PythonDataScienceHandbook/01.07-timing-and-profiling.html
line profiler https://github.com/rkern/line_profiler
%%capture
%matplotlib inline
import matplotlib.pyplot as plt
| import pandas as pd | |
| import os | |
| import json | |
| def flatten_dict(d): | |
| """ | |
| transform dict of dicts to single level dict | |
| """ | |
| fd = {} | |
| for k, v in d.items(): |
| import subprocess, os | |
| import re | |
| import click | |
| def find_free_gpu(amount_of_space): | |
| #in Mb | |
| nvidia_ouput = subprocess.check_output(['nvidia-smi']) | |
| pid_memory = re.findall('(\d+)MiB\s/\s(\d+)MiB', str(nvidia_ouput), re.DOTALL) | |
| print(pid_memory) | |
| for gpu_num, (used, whole) in enumerate(pid_memory): |
| import subprocess, os | |
| import re | |
| import click | |
| def find_free_gpu(amount_of_space): |
| function FindProxyForURL(url, host) { | |
| PROXY = "PROXY 10.211.55.4:3128" | |
| // Apple.com via proxy | |
| if (shExpMatch(host,"*philips.com*")) { | |
| return PROXY; | |
| } | |
| if (shExpMatch(host,"https://confluence.atlas.philips.com")) { | |
| return PROXY; | |
| } |
| def write_avi(frames, path): | |
| ''' | |
| frames - 3D numpy array (seq, height, width) | |
| path - result avi file path. Extantion of file have to be .avi | |
| ''' | |
| def norm(x): | |
| x = x - x.min() | |
| x = x / x.max() | |
| return (x*255).astype(np.uint8) | |
| frames = norm(frames) |
| import subprocess | |
| import re | |
| import pprint | |
| nvidia_ouput = subprocess.check_output(['nvidia-smi']) | |
| part = re.findall('Usage(.+)', str(nvidia_ouput), re.DOTALL) | |
| pid_memory = re.findall('\s(\d)\s+(\d+).+?\s(\d+MiB)', str(part), re.DOTALL) | |
| user_dict = {} | |
| print('='*50) | |
| for gpu_num, pid, memory in pid_memory: | |
| print('GPU number: ', gpu_num) |
jupyter profiling https://jakevdp.github.io/PythonDataScienceHandbook/01.07-timing-and-profiling.html
line profiler https://github.com/rkern/line_profiler
%%capture
%matplotlib inline
import matplotlib.pyplot as plt
| # %matplotlib inline | |
| %matplotlib notebook | |
| from ipywidgets import interact, widgets, Layout | |
| import matplotlib.pyplot as plt | |
| from matplotlib.image import AxesImage | |
| from IPython.display import display | |
| from numpy.fft import fftshift, fft2, ifft2, ifftshift | |
| import time | |
| from skimage import transform |
| first cosulution found was https://askubuntu.com/questions/1032633/18-04-screen-remains-blank-after-wake-up-from-suspend | |
| but it switch off second screen | |
| second i decide to install nvidia driver, and switch off Nouveau driver (open source nvidia river) http://us.download.nvidia.com/XFree86/Linux-x86_64/378.13/README/commonproblems.html#nouveau | |
| https://medium.com/@antonioszeto/how-to-install-nvidia-driver-on-ubuntu-18-04-7b464bab43e6 |