dotnet / dotnet/TorchSharp

TorchSharp memory issue

Open
#1,278 20 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
1.9k
Forks
228
PR merge metrics
No merged PRs in 30d

Description

```
m = torch.nn.Conv2d(3, 64, 7, 2, 3, bias=False).cuda()

for i in range(1000000):
x = torch.randn(1, 3, 224, 224, dtype=torch.float).cuda()
y = m.forward(x)
```
![image](https://github.com/dotnet/TorchSharp/assets/55724885/0b77a6c7-1938-43d6-a4ee-acbb178cffed)
```
var m=TorchSharp.torch.nn.Conv2d(3, 64, 7, 2, 3, bias: false).cuda();

for (int i = 0; i < 1000000; i++)
{
var x = torch.randn(1, 3, 224, 224).@float().cuda();
var y = m.forward(x);
}
```
![image](https://github.com/dotnet/TorchSharp/assets/55724885/b312576a-8c9d-4bb5-b8ba-2f3f8815c8e1)
In PyTorch, when using GPU inference, GPU memory can be released at the appropriate time. In TorchSharp, when using GPU inference, there is a GPU memory leak that requires manual release.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.