{"id":24860704,"url":"https://github.com/outofai/cudacanvas","last_synced_at":"2025-09-09T16:33:16.682Z","repository":{"id":216590422,"uuid":"741248483","full_name":"OutofAi/cudacanvas","owner":"OutofAi","description":"Python Module for PyTorch Tensor Visualisation in CUDA Eliminating CPU Transfer","archived":false,"fork":false,"pushed_at":"2025-01-30T13:05:21.000Z","size":160,"stargazers_count":37,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T18:18:44.428Z","etag":null,"topics":["cuda","deep-learning","gpu","machine-learning","neural-network","plotting","pypi","pypi-package","python","pytorch","tensor","visulization"],"latest_commit_sha":null,"homepage":"","language":"Python","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/OutofAi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"outofai","custom":null}},"created_at":"2024-01-10T02:08:04.000Z","updated_at":"2025-01-31T19:35:05.000Z","dependencies_parsed_at":"2024-01-15T13:41:07.287Z","dependency_job_id":"635d30a4-f724-4737-b1b8-5b128a79bff0","html_url":"https://github.com/OutofAi/cudacanvas","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.2857142857142857,"last_synced_commit":"0b85d2d7e14df3819788baf3211605b10dfdede8"},"previous_names":["outofai/cudacanvas"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutofAi%2Fcudacanvas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutofAi%2Fcudacanvas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutofAi%2Fcudacanvas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutofAi%2Fcudacanvas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OutofAi","download_url":"https://codeload.github.com/OutofAi/cudacanvas/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085325,"owners_count":21045139,"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","deep-learning","gpu","machine-learning","neural-network","plotting","pypi","pypi-package","python","pytorch","tensor","visulization"],"created_at":"2025-01-31T21:35:41.714Z","updated_at":"2025-04-09T18:18:50.315Z","avatar_url":"https://github.com/OutofAi.png","language":"Python","funding_links":["https://buymeacoffee.com/outofai","https://www.buymeacoffee.com/outofai"],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.buymeacoffee.com/outofai\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/-buy_me_a%C2%A0coffee-red?logo=buy-me-a-coffee\" alt=\"Buy Me A Coffee\"\u003e\u003c/a\u003e\n[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social\u0026label=Out%20of%20AI)](https://twitter.com/OutofAi)\n[![PyPI version](https://badge.fury.io/py/cudacanvas.svg)](https://badge.fury.io/py/cudacanvas)\n[![Downloads](https://static.pepy.tech/badge/cudacanvas)](https://pepy.tech/project/cudacanvas)\n\n![image](https://github.com/OutofAi/cudacanvas/assets/145302363/94f1ba88-0991-4690-b09b-7be480ee34ec)\n\n\n# cudacanvas : PyTorch Tensor Image Display in CUDA\n(Real-time PyTorch Tensor Image Visualisation in CUDA, Eliminating CPU Transfer)\n\nCudaCanvas is a simple Python module that eliminates CPU transfer for Pytorch tensors for displaying and rendering images in the training or evaluation phase, ideal for machine learning scientists and engineers. \n\nSimplified version that directly displays the image without explicit window creation (cudacanvas \u003e= v1.0.1)\n\n```python\nimport torch\nimport cudacanvas\n\n\n#REPLACE THIS with you training loop\nwhile (True):\n\n    #REPLACE THIS with you training code and generation of data\n    noise_image = torch.rand((4, 500, 500), device=\"cuda\")\n\n    #Visualise your data in real-time\n    cudacanvas.im_show(noise_image)\n\n    #OPTIONAL: Terminate training when the window is closed\n    if cudacanvas.should_close():\n        cudacanvas.clean_up()\n        #end process if the window is closed\n        break\n\n\n```\n\nYou can visualise the latent of Stable Diffusion during sampling in real-time whilst waiting for the steps to finish\n\n```python\n\nimport warnings\nwarnings.filterwarnings(\"ignore\")\nfrom diffusers import StableDiffusionPipeline\nimport torch\nimport cudacanvas\n\ndef display_tensors(pipe, step, timestep, callback_kwargs):\n    latents = callback_kwargs[\"latents\"]\n\n    with torch.no_grad():\n        image = pipe.vae.decode(latents / pipe.vae.config.scaling_factor, return_dict=False)[0]\n        image = image - image.min()\n        image = image / image.max()\n    \n    cudacanvas.im_show(image.squeeze(0))\n    \n    if cudacanvas.should_close():\n        cudacanvas.clean_up()\n        pipe._interrupt = True\n    \n    return callback_kwargs\n\npipeline = StableDiffusionPipeline.from_pretrained(\n    \"stabilityai/stable-diffusion-2-1-base\",\n    torch_dtype=torch.float16,\n    variant=\"fp16\"\n).to(\"cuda\")\n\nimage = pipeline(\n    prompt=\"A croissant shaped like a cute bear.\",\n    negative_prompt=\"Deformed, ugly, bad anatomy\",\n    callback_on_step_end=display_tensors,\n    callback_on_step_end_tensor_inputs=[\"latents\"],\n).images[0]\n\ncudacanvas.clean_up()\n\n```\n\n\n# Installation\nBefore instllation make sure you have torch with cuda support already installed on your machine\n\nWe aligned pytorch and cuda version with our package the supporting packages are torch (2.0.1, 2.1.2 and 2.2.2) and (11.8 and 12.1)\n\nIdentify your current torch and cuda version\n\n```python\nimport torch\ntorch.__version__\n```\n\nDepending on your torch and cuda you can install the relevant cudacanvas package, for the latest one matching the latest pytorch package you can simply download the latest package\n```\npip install cudacanvas\n```\nFor other torch and cuda packages put the torch and cuda version after that cudacanvas version for example for 2.1.2+cu118 the Cudacanvas package you require\nis 1.0.1.post212118\n\n```\npip install cudacanvas==1.0.1.post212118 --force-reinstall\n```\n\n# Support\nAlso support my channel ☕ ☕ : https://www.buymeacoffee.com/outofai\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutofai%2Fcudacanvas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutofai%2Fcudacanvas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutofai%2Fcudacanvas/lists"}