How to Run Code from anvil in GPU via uplink

What I’m trying to do:
I think i read that my server can uplink to anvil so that anvil can run my pytorch code that has a gpu in it. Can my server with gpu can call anvil projects like a library?

so i can keep all my code in anvil just to keep them all in one place but have my gpu server do anvil server calls to use the gpu resources and return it back to anvil?
or does all gpu related code have to live in my gpu server?

What I’ve tried and what’s not working:
I tried it and it open a websocket connection but doesn’t recognize the project in anvil as a module when I tried to import it. Is it not possible or did i do something wrong?
Code Sample:

To my understanding the anvil.server.connect() creates a websocket communication line with the anvil-environment from you own system. [link]

This does not provide your local python environment a way to import something from your anvil environment (import evolive_ai).

The way forward is to move your pytorch code to your local system and give the functions you want to call from anvil a decorator (@anvil.server.callable).

2 Likes