Hey there !
I’m currently experimenting around with using cuda and opengl (pycuda/glumpy) to draw tensors to the screen. I’ve found a gist that seems to have implemented exactly what i want to do. The problem is that the project is quite old and it uses a few deprecated apis.
The gist:
  

      gist.github.com
  

  
    https://gist.github.com/victor-shepardson/5b3d3087dc2b4817b9bffdb8e87a57c4 5

  pytorch-glumpy.py
  from contextlib import contextmanager
import numpy as np
import torch
from torch import Tensor, ByteTensor
import torch.nn.functional as F
from torch.autograd import Variable
import pycuda.driver
from pycuda.gl import graphics_map_flags
from glumpy import app, gloo, gl

    This file has been truncated. show original




  

  
    
    
  

  


Being new to pytorch and machine learning in general, i was wondering if any of you guy’s have a few hints for me on how to get this working.
The packages i have installed:
python - 3.9.7
pytorch - 1.9.0+cu111
pycuda - 2021.1+cuda114
glumpy - 1.2.0
Since this is only doing inference there are quite a few Variable(state, volatile=True). Variable seems to be deprecated, which is easily solved by doing the processing with torch.no_grad():.
What i’m struggling with is converting the tensor to the proper format of the texture. This is from line 99 onwards. Its mainly line 99 that currently throws RuntimeError: t() expects a tensor with <= 2 dimensions, but self is 3D.
I’d appreciate any help.
Cheers