This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch.cuda | |
import torch.cuda.memory as cumem | |
import sys | |
import ctypes as C | |
GB = 1 << 30 | |
def get_cuda_memory(): | |
handle = C.cdll.LoadLibrary("libcudart.so") | |
free, total = C.c_long(), C.c_long() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Use Vim settings, rather then Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
" TODO: this may not be in the correct place. It is intended to allow overriding <Leader>. | |
" source ~/.vimrc.before if it exists. | |
if filereadable(expand("~/.vimrc.before")) | |
source ~/.vimrc.before | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <unistd.h> | |
#include <iostream> | |
#include <nvml.h> | |
#define cudaSafeCall(call) \ | |
do { \ | |
cudaError_t err = call; \ | |
if (cudaSuccess != err) { \ | |
fprintf (stderr, "Cuda error in file '%s' in line %i : %s.", \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onnx | |
import sys | |
name = sys.argv[1] | |
model = onnx.load(name) | |
onnx.checker.check_model(model) | |
print(onnx.helper.printable_graph(model.graph)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RUN wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run | |
RUN chmod +x cuda_10.2.89_440.33.01_linux.run && \ | |
./cuda_10.2.89_440.33.01_linux.run --silent --toolkit | |
# After installing CUDA, you need to add the env vars below, otherwise you'll get CUDA runtime version/driver | |
# version issue, even if you're using nvidia-docker. | |
ENV LIBRARY_PATH=/usr/local/cuda/lib64/stubs | |
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# precondition: d is power of 2 | |
def mod_pow2(n, d): | |
return ( n & (d-1) ) | |
print(n, "mod" , d , "is", mod_pow2(6, 4)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from time import time | |
# initialize CUDA, to not count startup later | |
foo = torch.ones(1).cuda() | |
MB = 1 << 20 | |
# 27 MB tensor | |
NUM_MB = 27 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Demonstrate how to pass IPC handles to GPU data between processes in Python. | |
""" | |
import ctypes | |
import numpy as np | |
import multiprocessing as mp | |
import zmq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import numpy as np | |
import sqlite3 as lite | |
import sys | |
from contextlib import ContextDecorator | |
class DbContext(ContextDecorator): | |
def __init__(self, file_path): | |
self.file_path = file_path |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.