Skip to content

Instantly share code, notes, and snippets.

@ohjho
ohjho / using_CUDA.md
Last active February 1, 2024 21:11
Tips and Tricks working with CUDA

Tips and Tricks for using CUDA

nvidia-smi is very useful, in fact you can hack together a little nvtop with just watch -n 1 "nvidia-smi". Note, however, that the CUDA version in the top right corner of the output is the highest CUDA version supported, NOT installed.

You get also get your GPU's name with nvidia-smi --query-gpu=gpu_name --format=csv (credit to this interesting forumn thread)

And to get your CUDA driver version use nvcc --version

Docker resources

nvidia publishs a lot of linux docker images with different versions of CUDA installed on dockerhub

@ohjho
ohjho / google_CDNHacks.md
Created March 28, 2023 05:44
Hacks for using Google to store and share stuff
@ohjho
ohjho / peak_signal_detect.md
Last active August 3, 2021 04:02
Notes for Peak Detection in Time Series

Intro

peak signal detection in a time series is non-trivial. It's simple if a window is defined as in this simple one-line solution in numpy or using scipy.signal.find_peaks however, to do this with noisy data without defining a window this becomes very tricky very quickly per here and here

using scipy with defined window

Plotly has a very simple example here and

@ohjho
ohjho / fast_neural_style.md
Last active July 23, 2021 03:18
Fast Neural Style Transfer with PyTorch Example

Clone from PyTorch Example

git clone --depth 1 https://github.com/pytorch/examples.git pytorch_examples
cd pytorch_examples/fast_neural_style/

Install requirements

check PyTorch official website, as of July 2021, with a g4dn.xlarge running CUDA 11.1 I used:

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
@ohjho
ohjho / efs_mounting.md
Last active March 3, 2021 07:49
EFS mounting on AWS EC2 for Data Scientist

Create EFS

make sure it's in the same reigon in the same VPC as your EC2. Furthermore, your EFS also has to be in the same Security Group (with NFS access)

Mounting the EFS

follow this guide on how to mount your EFS on to a new EC2 instance

you can double check that it's mounted by df -h or mount | grep efs

your newly launched EC2 instance should have the EFS mount instructions in /etc/fstab

@ohjho
ohjho / nvidia-smi-hacks.md
Last active February 2, 2021 10:36
hacks using `nvidia-smi` to monitor GPU stats from the terminal

A fake nvtop

watch -n 0.5 nvidia-smi

more specific stats

nvidia-smi --format=csv --query-gpu=power.draw,utilization.gpu,fan.speed,temperature.gpu,memory.used,memory.free
@ohjho
ohjho / docker_cheatsheet.md
Last active January 13, 2024 12:38
my docker cheatsheet

basics

  • check that docker is working: docker run hello-world
  • prune images: docker image prune -a
  • prune containers: docker container prune
  • check nvidia-docker2 is working (with CUDA 10.0 in base): docker run --rm --gpus all nvidia/cuda:10.0-runtime nvidia-smi
  • build with Dockerfile: docker build -t your_image_name .
  • run built image as container: docker run --name your_container_name your_image_name (for extra options see here)
  • kill running container: docker kill your_container_name
@ohjho
ohjho / change_docker_image_directory.md
Created January 19, 2021 04:51
How to Change Docker's Image Installation Directory

To remove unused images, docker image prune -a, and containers , docker container prune

1. Stop Docker

sudo service docker stop then make sure docker is stop with ps aux| grep docker

2. Backup current docker directory

sudo cp -r /var/lib/docker /your/storage/dir

3. Update Docker Configs per this post

@ohjho
ohjho / torchserve_install.md
Last active September 8, 2021 01:52
how to install torchserve and get your first model running

Installing TorchServe

Machine Type

GCP, Ubuntu instance (Canonical, Ubuntu, 16.04 LTS, amd64 xenial image built on 2020-06-10, supports Shielded VM features)

To get this example to actually work, I followed the official documentation, this blog post by AWS, and this YouTube demo

  1. Install Java 11
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
@ohjho
ohjho / search_and_kill_pid.md
Last active July 15, 2020 08:27
Search and Kill Process in Linux land

Search for your Process's ID:

ps aux | grep 'your search term'

Kill it gently (assuming our id is 93735):

kill 93735