{"id":13543112,"url":"https://github.com/gorgonia/cu","last_synced_at":"2025-04-04T12:05:11.366Z","repository":{"id":41582675,"uuid":"82639579","full_name":"gorgonia/cu","owner":"gorgonia","description":"package cu provides an idiomatic interface to the CUDA Driver API.","archived":false,"fork":false,"pushed_at":"2024-06-23T23:47:19.000Z","size":708,"stargazers_count":498,"open_issues_count":27,"forks_count":65,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-28T11:11:52.981Z","etag":null,"topics":["cuda","cuda-driver-api","go","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gorgonia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-21T05:24:11.000Z","updated_at":"2025-03-26T06:30:19.000Z","dependencies_parsed_at":"2024-01-16T15:47:36.731Z","dependency_job_id":"f4fb06f9-d5d2-4262-990e-9fc416f7ecec","html_url":"https://github.com/gorgonia/cu","commit_stats":null,"previous_names":["chewxy/cu"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorgonia%2Fcu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorgonia%2Fcu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorgonia%2Fcu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorgonia%2Fcu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gorgonia","download_url":"https://codeload.github.com/gorgonia/cu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174413,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cuda","cuda-driver-api","go","golang"],"created_at":"2024-08-01T11:00:23.339Z","updated_at":"2025-04-04T12:05:11.346Z","avatar_url":"https://github.com/gorgonia.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# cu [![GoDoc](https://godoc.org/gorgonia.org/cu?status.svg)](https://godoc.org/gorgonia.org/cu)\n\nPackage `cu` is a package that interfaces with the [CUDA Driver API](http://docs.nvidia.com/cuda/cuda-driver-api/). This package was directly inspired by Arne Vansteenkiste's [`cu` package](https://github.com/barnex/cuda5).\n\n# Why Write This Package? #\nThe main reason why this package was written (as opposed to just using the already-excellent [`cu` package](https://github.com/barnex/cuda5)) was because of errors. Specifically, the main difference between this package and Arne's package is that this package returns errors instead of panicking.\n\nAdditionally another goal for this package is to have an idiomatic interface for CUDA. For example, instead of exposing `cuCtxCreate` to be `CtxCreate`, a nicer, more idiomatic name `MakeContext` is used. The primary goal is to make calling the CUDA API as comfortable as calling Go functions or methods. Additional convenience functions and methods are also created in this package in the pursuit of that goal.\n\nLastly, this package uses the latest [CUDA toolkit](https://developer.nvidia.com/cuda-toolkit) whereas the original package `cu` uses a number of deprecated APIs.\n\n# Installation #\n\nThis package is go-gettable: `go get -u gorgonia.org/cu`\n\nThis package mostly depends on built-in packages. There are two external dependencies:\n\n* [errors](https://github.com/pkg/errors), which is licenced under a [MIT-like](https://github.com/pkg/errors/blob/master/LICENSE) licence. This package is used for wrapping errors and providing a debug trail.\n* [assert](https://github.com/stretchr/testify), which is licenced under a [MIT-like](https://github.com/stretchr/testify/blob/master/LICENSE) licence. This package is used for quick and easy testing.\n\nHowever, package `cu` DOES depend on one major external dependency: CUDA. Specifically, it requires the CUDA driver. Thankfully nvidia has made this rather simple - everything that is required can be installed with one click: [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit).\n\n\nTo verify that this library works, install and run the `cudatest` program, which accompanies this package:\n\n```\ngo install gorgonia.org/cu/cmd/cudatest@latest\ncudatest\n```\n\nYou should see something like this if successful:\n\n```\nCUDA version: 10020\nCUDA devices: 1\n\nDevice 0\n========\nName      :\t\"TITAN RTX\"\nClock Rate:\t1770000 kHz\nMemory    :\t25393561600 bytes\nCompute   : \t7.5\n```\n\n## Windows ##\n\nTo setup CUDA in Windows:\n\n1. Install CUDA Toolkit\n2. Add `%CUDA_PATH%/bin` to your `%PATH%` environment variable (running `nvcc` from console should work)\n3. Make a symlink `mklink /D C:\\cuda \"c:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\"` (alternatively, install CUDA toolkit to `C:\\cuda\\`)\n\nTo setup the compiler chain (MSYS2):\n\n1. Install MSYS2 (see https://www.msys2.org/)\n2. In `c:\\msys64\\msys2_shell.cmd` uncomment the line with `set MSYS2_PATH_TYPE=inherit` (this makes Windows PATH variable visible)\n3. Install `go` in MSYS2 (64 bit) with `pacman -S go`\n\nAlternatively, if you already have Go setup and only need to install cgo dependencies:\n\n1. Install TDM-GCC (see https://jmeubank.github.io/tdm-gcc/download/)\n2. Ensure `gcc` is in `%PATH%` environment variable (running `gcc` from console should work)\n\n## FAQ ##\n\nHere is a common list of problems that you may encounter.\n\n### ld: cannot find -lcuda (Linux) ###\n\nChecklist:\n\n* [ ] Installed CUDA and applied the relevant [post-installation steps](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions)?\n* [ ] Checked that the sample programs in the CUDA install all works?\n* [ ] Checked the output of `ld -lcuda --verbose`?\n* [ ] Checked that there is a `libcuda.so` in the given search paths?\n* [ ] Checked that the permissions on `libcuda.so` is correct?\n\n**Note**, depending on how you install CUDA on Linux, sometimes the `.so` file is not properly linked. For example: in CUDA 10.2 on Ubuntu, the default `.deb` installation installs the shared object file to `/usr/lib/x86_64-linux-gnu/libcuda.so.1`. However `ld` searches only for `libcuda.so`. So the solution is to symlink `libcuda.so.1` to `libcuda.so`, like so:\n\n```\nsudo ln -s /PATH/TO/libcuda.so.1 /PATH/TO/libcuda.so\n```\n\nBe careful when using `ln`. This author spent several hours being tripped up by permissions issues.\n\n\n\n\n# Progress #\nThe work to fully represent the CUDA Driver API is a work in progress. At the moment, it is not complete. However, most of the API that are required for GPGPU purposes are complete. None of the texture, surface and graphics related APIs are handled yet. Please feel free to send a pull request.\n\n## Roadmap ##\n\n* [ ] Remaining API to be ported over\n* [x] All texture, surface and graphics related API have an equivalent Go prototype.\n* [x] Batching of common operations (see for example `Device.Attributes(...)`\n* [x] Generic queueing/batching of API calls (by some definition of generic)\n\n\n# Contributing #\nThis author loves pull requests from everyone. Here's how to contribute to this package:\n\n1. Fork then clone this repo:\n    `git clone git@github.com:YOUR_USERNAME/cu.git`\n2. Work on your edits.\n3. Commit with a good commit message.\n4. Push to your fork then [submit a pull request](https://gorgonia.org/cu/compare/).\n\nWe understand that this package is an interfacing package with a third party API. As such, tests may not always be viable. However, please do try to include as much tests as possible.\n\n\n# Licence #\nThe package is licenced with a MIT-like licence. Ther is one file (`cgoflags.go`) where code is directly copied  and two files (`execution.go` and `memory.go`) where code was partially copied from Arne Vansteenkiste's package, which is unlicenced (but to be safe, just assume a GPL-like licence, as [mumax/3](https://github.com/mumax/3) is licenced under GPL).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorgonia%2Fcu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgorgonia%2Fcu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorgonia%2Fcu/lists"}