Skip to content

Instantly share code, notes, and snippets.

View hidetatz's full-sized avatar
🐦

Hidetatz Yaginuma hidetatz

🐦
View GitHub Profile
@hidetatz
hidetatz / relu.cu
Last active August 4, 2025 23:43
Call CUDA Kernel from Python using CUDA Runtime API
// relu
extern "C" __global__ void kern(float* d1, float* result) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
float d2 = d1[idx];
result[idx] = d2 > 0 ? d2 : 0.0;
}
@hidetatz
hidetatz / mnist_forward.dot
Created August 2, 2025 04:11
mnist forward path
digraph mnist {
{
// params
node [style=filled, fillcolor=green, fontcolor=white, shape=box];
w1[label="w1 (784, 1000)"];
w2[label="w2 (1000, 1000)"];
w3[label="w3 (1000, 10)"];
}
@hidetatz
hidetatz / main.cu
Last active February 15, 2025 11:18
Call JIT compiled CUDA from Go using Cgo with dlopen
#include <cuda_runtime.h>
#include <stdio.h>
#define CHECK_CUDA_ERROR(call) { \
cudaError_t e = call; \
if (e != cudaSuccess) { \
snprintf(err_buf, 256, "CUDA[%d]: %d: %s\n", __LINE__, e, cudaGetErrorString(e)); \
return; \
} \
}
@hidetatz
hidetatz / Dockerfile
Last active July 7, 2025 16:10
Docker + Pytorch + Python3.11.6 + Poetry environment
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=all
ENV DEBIAN_FRONTEND=noninteractive
# configure locale
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
@hidetatz
hidetatz / .bashrc
Last active August 3, 2024 23:36
dotfiles
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
source /usr/share/bash-completion/bash_completion