mirror of
https://github.com/huggingface/kernels.git
synced 2025-10-20 20:56:31 +08:00
7f75050a8a482894e0d976bbacc73c84056af67c
kernels
Make sure you have torch==2.5.1+cu124
installed.
import torch
from kernels import get_kernel
# Download optimized kernels from the Hugging Face hub
activation = get_kernel("kernels-community/activation")
# Random tensor
x = torch.randn((10, 10), dtype=torch.float16, device="cuda")
# Run the kernel
y = torch.empty_like(x)
activation.gelu_fast(y, x)
print(y)
Docker Reference
build and run the reference example/basic.py in a Docker container with the following commands:
docker build --platform linux/amd64 -t kernels-reference -f docker/Dockerfile.reference .
docker run --gpus all -it --rm -e HF_TOKEN=$HF_TOKEN kernels-reference
Description
Languages
Python
98.7%
Nix
1.2%