{"id":18008959,"url":"https://github.com/mrnerf/mnist_cuda","last_synced_at":"2025-06-19T20:36:05.408Z","repository":{"id":182302247,"uuid":"668271621","full_name":"MrNeRF/MNIST_CUDA","owner":"MrNeRF","description":"CUDA and C++ implementation of a Neural Network architecture training CUDA ","archived":false,"fork":false,"pushed_at":"2023-07-31T18:23:43.000Z","size":138,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T09:11:14.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrNeRF.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":"2023-07-19T12:19:52.000Z","updated_at":"2025-02-24T08:58:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf9641e8-433d-4798-bd8f-10c42f776b10","html_url":"https://github.com/MrNeRF/MNIST_CUDA","commit_stats":null,"previous_names":["mrpaja/mnist_cuda"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MrNeRF/MNIST_CUDA","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNeRF%2FMNIST_CUDA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNeRF%2FMNIST_CUDA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNeRF%2FMNIST_CUDA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNeRF%2FMNIST_CUDA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrNeRF","download_url":"https://codeload.github.com/MrNeRF/MNIST_CUDA/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNeRF%2FMNIST_CUDA/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260826830,"owners_count":23068851,"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":[],"created_at":"2024-10-30T02:08:20.117Z","updated_at":"2025-06-19T20:36:00.397Z","avatar_url":"https://github.com/MrNeRF.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# MNIST Classifier with CUDA and C++\n\nThis project is a MNIST classifier using CUDA and C++ to code an MLP from scratch. \nIn its tests it uses the torch C++ API to assure correct implementation. It achieves ~97% on MNIST dataset.\n\nAttention: This not yet in a clean version, but it is working. It is not optimized at all. \nTested with NVIDIA RTX 4090.\n\nRight now, running torch_speedtest vs cuda_speedtest the runtime is 16.01 sec vs 8.561 sec on my hardware.\nhttps://twitter.com/janusch_patas/status/1686016066537840641?s=20\nThe naive CUDA implementation is already twice as fast.\n\n## Dependencies\n\n- CMake (version \u003e= 3.22)\n- CUDA Toolkit (version \u003e= 12.0) \n- PyTorch (libtorch)\n- Google Test (release-1.10.0)\n- Cutlass (version \u003e= 3.1)\n\nIt might also work with a lower version of CUDA, but that is the only one I have tested.\nCMake version might be also considerable lower. Just test it.\n## Installation\n\nOpen a terminal and navigate to the directory where you want the project to clone.\n\n```bash\ngit clone https://github.com/MrNeRF/MNIST_CUDA\ncd MNIST_CUDA\n```\n### libtorch\n\nDownload the libtorch library using the following command:\n\n```bash\nwget https://download.pytorch.org/libtorch/test/cu118/libtorch-cxx11-abi-shared-with-deps-latest.zip  \n```\n\nThis will download a zip file named `libtorch-shared-with-deps-latest.zip`. To extract this zip file, use the command:\n\n```bash\nunzip libtorch-cxx11-abi-shared-with-deps-latest.zip -d external/\nrm libtorch-cxx11-abi-shared-with-deps-latest.zip\n```\n\nThis will create a folder named `libtorch` in the `external` directory of your project.\n\n### MNIST Data\n\nThe MNIST data can be downloaded using the following command:\n\n```bash\ncd data\nwget http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz\nwget http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz\nwget http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz\nwget http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz\n```\n\nThese commands will download four gzip files. To extract these gzip files, use the command:\n\n```bash\ngunzip train-images-idx3-ubyte.gz\ngunzip train-labels-idx1-ubyte.gz\ngunzip t10k-images-idx3-ubyte.gz\ngunzip t10k-labels-idx1-ubyte.gz\ncd ..\n```\n\n\n## Building the Project\n\nTo build the project, follow these steps:\n1. Create a new directory named `build` and navigate into it:\n\n    ```bash\n    mkdir build \u0026\u0026 cd build\n    ```\n\n2. Run the CMake configuration:\n\n    ```bash\n    cmake -DCMAKE_BUILD_TYPE=Release ..\n    ```\n\tIf you have problems to configure the build, you might look up the graphics card architecture you are using.\n\tThen replace CUDA_ARCHITECTURE 89 with the number of your architecture.\n\n3. Finally, compile the project:\n\n    ```bash\n    make -j$(nproc)\n    cd ..\n    ```\n\nThis will create an executable named `mnist_cuda` in the `build` directory.\n\nRun it:\n```bash\n./build/mnist_cuda data\n```\n\n## Running the Tests\n\nAfter building the project, you can run the tests with the following command:\n\n```bash\n./build/cuda_kernel_tests\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrnerf%2Fmnist_cuda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrnerf%2Fmnist_cuda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrnerf%2Fmnist_cuda/lists"}