Shell打通跳板机访问剪贴板
背景
之前写了 vim 中打通开发机和 mac 剪贴板的方式, 最近突发奇想感觉直接在 shell 里面也可以实现, 下面来看看
脚本
#!/bin/bash
# 检查是否有输入
if [ -t 0 ]; then
echo "Usage: cat file | $0"
exit 1
fi
# 读取标准输入内容
content=$(cat)
# 使用 base64 编码
encoded=$(echo -n "$content" | base64 -w 0)
# 输出 ANSI 控制序列到终端
echo -e "\e]52;c;${encoded}\a"
使用
chmod +x copy
mv copy ~/local/bin
cat file_you...
Shell常用的提效工具,脚本
写在前面
alias 篇
export LANG="zh_CN.utf8"
export LC_CTYPE="zh_CN.UTF-8"
export MANPATH=/usr/local/share/man:$HOME/local/share/man:$MANPATH
ulimit -c unlimited
alias vi=vim
alias vimdiff='vimdiff -c "windo set wrap" '
alias vb='vi ~/.bashrc'
alias vt='vi ~/code/tool/linux_tool.sh'
alias sb='source ~/.bashrc'
alias vv="vi ~/.vimrc"
alias ll="ls -a...
Cuda性能测试工具与 cuda 常用命令行
写在前面
cuda工具集
查询显卡的算力
nvidia-smi --query-gpu=name,compute_cap --format=csv
name, compute_cap
NVIDIA A10, 8.6
name, compute_cap
NVIDIA L20, 8.9
nvprof
自测计时类
//utils.h
#pragma once
#include <chrono>
#include <iostream>
#include <cuda_runtime.h>
using namespace std::chrono;
#define CUDA_CHECK(call) ...
Cuda 实现softmax与优化
写在前面
https://leetgpu.com/challenges/softmax
https://leetgpu.com/challenges/softmax-attention
前置知识
safe-softmax 的原理与推导
https://arxiv.org/pdf/1805.02867
传统的 softmax 是
\(y=Softmax(x)\ \ \text{define as:}\\
y_i=\frac{e^{x_i}}{\sum\limits_{j=1}^Ve^{x_j}}\)
但是直接计算的过程中存在过大或者过小的问题. 于是有了下面的 safe-softmax
\(y_i=\frac{e^{x_i-\max_{k=1}^Vx_k...
Cuda 实现归约 reduction 与优化
写在前面
https://leetgpu.com/challenges/reduction
可以说是 CUDA 入门的第一个算子, 对于理解并行编程比较有帮助
reduction 实现与 性能测试(CPU vs GPU)
#include "utils.h"
constexpr int BLOCK_SIZE = 256;
__global__ void block_reduce_v1(const float* input, float* partial, int N) {
__shared__ float cache[BLOCK_SIZE]; // BLOCK_SIZE must use global variable
int tid = thread...
Cuda核函数的定义与参数
CUDA 核函数参数的配置CUDA execution-configuration;
Any call to a __global__ function must specify the execution configuration for that call. The execution configuration defines the dimension of the grid and blocks that will be used to execute the function on the device, as well as the associated stream (see CUDA Runtime for a description of streams)...
矩阵乘法基础cuda实现
写在前面
学一下 CUDA. 关键在于并行思维. 当然还要了解一些矩阵/线性代数相关的内容, 还有算法/深度学习的一些公式的推导. 这里先做一下 leetgpu 里面的第二题. 矩阵乘法.
https://leetgpu.com/challenges/matrix-multiplication
$M\times N$的矩阵 A 还有$N\times K$的矩阵 B 相乘, 得到$M\times K$ 的矩阵 C. 用 CUDA 实现. 传入的就是每一个矩阵线性化之后的一维数组.
基本实现
#include <cuda_runtime.h>
__global__ void matrix_multiplication_kernel(const float* ...
共计 492 篇文章,62 页。
您是Zorch的第 个小伙伴
Hits