Skip to content

Instantly share code, notes, and snippets.

@dhy2000
dhy2000 / ipv4-cidr-exclude-rfc1918.txt
Last active August 18, 2025 06:52
IPv4 CIDR ranges exclude Private Addresses (RFC1918).
0.0.0.0/5
8.0.0.0/7
11.0.0.0/8
12.0.0.0/6
16.0.0.0/4
32.0.0.0/3
64.0.0.0/2
128.0.0.0/3
160.0.0.0/5
168.0.0.0/6
@dhy2000
dhy2000 / launch.json
Created May 15, 2025 03:16
VSCode Debugger launch.json to connect to GDB Server.
{
"configurations": [
{
"name": "GDB Connect",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/executable",
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerServerAddress": "localhost:9999",
@dhy2000
dhy2000 / vectorAdd.cu
Created May 6, 2025 09:06
vectorAdd of cuda-samples.
/**
* Vector addition: C = A + B.
*
* This sample is a very basic sample that implements element by element
* vector addition. It is the same as the sample illustrating Chapter 2
* of the programming guide with some additions like error checking.
*/
#include <stdio.h>
@dhy2000
dhy2000 / base-devel-debian.dockerfile
Last active June 10, 2025 06:36
Base of my development docker (debian 12).
FROM debian:bookworm
# setup apt
RUN sed -i 's#deb.debian.org#mirrors.ustc.edu.cn#g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && apt-get install -y apt-transport-https ca-certificates gpg && \
sed -i 's#http#https#g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && apt-get upgrade -y && apt-get install -y wget curl && apt-get clean
# install llvm
RUN wget --no-hsts -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
@dhy2000
dhy2000 / set_cuda_env.sh
Last active August 19, 2025 07:50
Setup environment variables for bash/zsh.
# Environment setup script for bash/zsh.
_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]:-$0}"))
# --- ^_^ YOU CAN EDIT BELOW ^_^ --- #
_name="CUDA"
_components=(
bin/nvcc
)
_add_path=(
bin
@dhy2000
dhy2000 / Win11-Setup.md
Last active March 11, 2025 03:40
Setup guide for Windows 11 (Home Edition)

Windows 11 Setup

跳过联网

Windows 11 家庭版初始化阶段,选择完键盘布局后可能进入强制连接无线网络并登录微软账号的环节(如果连接了网线需要先拔掉)。跳过无线联网的方法参考这篇CSDN博客,总共提到了三种方法,推荐采用第二种:

Shift+F10 或 Shift+Fn+F10 打开 cmd,输入 oobe\bypassnro.cmd 命令(如果 cmd 窗口不是当前焦点,无法输入命令,需按 Alt+Tab 切换窗口),等待系统重启后,来到联网这步选择“我没有 Internet 连接”,下一步选择“继续执行受限的设置”即可设置本地的用户名和密码,无需登录微软账户。

常规设置

@dhy2000
dhy2000 / ssh-config
Last active February 15, 2025 08:08
My SSH Config file: ~/.ssh/config
## ignore known_hosts
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
## keep alive
ServerAliveInterval 30
ServerAliveCountMax 100
Compression yes
@dhy2000
dhy2000 / blas_bench.cu
Last active January 2, 2025 10:15
GPU Benchmark using cuBLAS.
// nvcc blas_bench.cu -o blas_bench -lcublas
/*
Hipify
hipify-clang blas_bench.cu -o blas_bench.hip
Manually replace call of cublasGemmEx (with code in comment)
Build with HIP
hipcc -x hip blas_bench.hip -o blas_bench_hip -I /opt/rocm/include/hipblas -L /opt/rocm/lib -lhipblas
@dhy2000
dhy2000 / Llama-2.md
Last active March 10, 2025 08:21
Llama structure and inference.

模型结构以及推理过程

Config

模型尺寸:

  • 隐藏层大小 hidden_size (输入句子 embedding 之后的维度)
  • 隐藏层数量 num_hidden_layers (即 Decoder Layer 的数量)
  • 中间层大小 intermediate_size (MLP 层上投影和门投影之后的维度)
@dhy2000
dhy2000 / 1-Setup.md
Last active May 6, 2025 12:30
Development server setup.

服务器开发环境建立

Zsh 配置

选用 oh-my-zsh 框架以及 powerlevel10k 主题。

主题下载

下载 oh-my-zsh 配置框架及实用插件,以及 powerlevel10k 主题: