Skip to content

Instantly share code, notes, and snippets.

View leimingyu's full-sized avatar

Leiming Yu leimingyu

View GitHub Profile
@leimingyu
leimingyu / save_opencl_program_binary.cpp
Created September 21, 2018 14:15
save opencl program binary
bool save_program_bin(cl_program program, cl_device_id device, const char *filename)
{
// step 1: find out deivces attached to the program
cl_uint devNum = 0;
cl_int ret;
ret = clGetProgramInfo(program, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &devNum, NULL);
if(ret != CL_SUCCESS) {
printf("\n[OMG]Failed to query for the number of devices.\n");
return false;
}
@leimingyu
leimingyu / rocm_version.sh
Created September 17, 2018 20:47
check installed ROCm version
cat /opt/rocm/.info/version && echo -e '\n'
@leimingyu
leimingyu / stop-MPS-as-root.sh
Created September 13, 2018 14:13
stop nvidia mps server ($sudo ./stop-MPS-as-root.sh)
#!/bin/bash
echo quit | nvidia-cuda-mps-control
@leimingyu
leimingyu / start-MPS-as-root.sh
Created September 13, 2018 14:01
start nvidia mps server ($sudo ./start-MPS-as-root.sh)
#!/bin/bash
export CUDA_VISIBLE_DEVICES="0"
nvidia-smi -i 0 -c DEFAULT
nvidia-cuda-mps-control -d
@leimingyu
leimingyu / undo_last_commit.sh
Created August 31, 2018 20:41
undo_last_commit
git reset --hard HEAD^
git push origin master --force
#!/bin/bash
cut -d: -f1 /etc/passwd
@leimingyu
leimingyu / notebook2py.sh
Created March 9, 2018 01:45
Convert jupyter notebook to py file and execute the python file without launching notebook.
#!/bin/bash
notebook_file=$1
echo $notebook_file
file_name=`echo "$notebook_file" | cut -d'.' -f1`
echo $file_name
py_file=$file_name".py"
@leimingyu
leimingyu / client.py
Created December 11, 2017 02:08 — forked from micktwomey/client.py
python multiprocessing socket server example
import socket
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 9000))
data = "some data"
sock.sendall(data)
result = sock.recv(1024)
print result
sock.close()
@leimingyu
leimingyu / kill_target_ps.md
Last active November 29, 2017 17:11
list process and kill the target pid
ps aux | grep rCUDA  | tee -a rcuda_ps
pids=`awk -F " " '{print $2}' rcuda_ps`
for i in "${pids[@]}"; do kill -9 $i; done
@leimingyu
leimingyu / makefile_notes.md
Last active November 24, 2017 15:30
makefile note

print hostname in makefile

host_name := $(shell hostname -s)                                               
$(info Host Name $(host_name)) 

set up env variable using if-else

ifeq ($(host_name),mcx1)                                                        
CUDA_PATH ?= /pub/cuda-8.0