Skip to content

Instantly share code, notes, and snippets.

View deeperlearner's full-sized avatar
😃

Chuck Liu deeperlearner

😃
View GitHub Profile
import tensorflow as tf
if tf.test.gpu_device_name():
print(f"Default GPU Device: {tf.test.gpu_device_name()}")
else:
print("Please install GPU version of TF")
@deeperlearner
deeperlearner / wgetgdrive.sh
Created February 20, 2021 13:14
wgetgdrive.sh
#!/bin/bash
# Get file (>100MB) from Google Drive
# ./wgetgdrive.sh $1 $2
ID=$1
FILE_NAME=$2
URL="https://docs.google.com/uc?export=download&id=$ID"
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate $URL -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=$ID" -O $FILE_NAME && rm -rf /tmp/cookies.txt
@deeperlearner
deeperlearner / torch_gpu_test.py
Created February 20, 2021 13:13
torch_gpu_test.py
import torch
import sys
print('__Python VERSION:', sys.version)
print('__pyTorch VERSION:', torch.__version__)
print("Whether CUDA is available:", torch.cuda.is_available())
print('__CUDA VERSION', )
from subprocess import call
print('__CUDNN VERSION:', torch.backends.cudnn.version())
print('__Number CUDA Devices:', torch.cuda.device_count())
print('__Devices')
@deeperlearner
deeperlearner / photo_resizer.py
Created November 14, 2020 08:57
photo_resizer.py
import sys
from pathlib import Path
from PIL import Image
# usage: python3 photo_resizer.py img.png
img_file = sys.argv[1]
path = Path(img_file)
assert path.parent == Path(), "The image must in the same directory with photo_resizer.py"