Skip to content

Instantly share code, notes, and snippets.

View ralphscheu's full-sized avatar
🏠
Working from home

Ralph Scheuerer ralphscheu

🏠
Working from home
View GitHub Profile
@ralphscheu
ralphscheu / get_free_gpu.py
Created July 5, 2021 18:32
auto-select free CUDA devices for training in python
import subprocess, sys
import numpy as np
from io import StringIO
def get_free_gpu(num_gpus=1):
""" returns: comma-separated list of device ids, e.g. to set CUDA_VISIBLE_DEVICES for PyTorch """
output = subprocess.check_output(["nvidia-smi -q -d Memory | grep -A4 GPU | grep Free"], shell=True).decode()
memory_available = np.array( [int(x.split()[2]) for x in StringIO(output)] )
memory_available = np.where( memory_available == 11018 )[0]
@ralphscheu
ralphscheu / seafile_remote_backup.sh
Created July 10, 2022 11:55
Remote Backup Script of Seafile userdata using seaf-fuse and rclone
#!/usr/bin/env bash
if [ -z "$(ls -A /mnt/seafile-fuse)" ]; then
echo "Mountpoint /mnt/seafile-fuse empty, mounting Seafile using seaf-fuse.sh..."
echo "/opt/seafile/seafile-server-latest/seaf-fuse.sh start /mnt/seafile-fuse"
/opt/seafile/seafile-server-latest/seaf-fuse.sh start /mnt/seafile-fuse
fi
if [ -z "$(ls -A /mnt/seafile-fuse)" ]; then
echo "Failed to mount Seafile: /mnt/seafile-fuse still empty! Aborting..."