Boris Tseytlin
11/03/2022, 5:44 PMpytorch/pytorch
.
It fails because prefect is not installed
17:43:10.947 | INFO | prefect.infrastructure.docker-container - Pulling image 'pytorch/pytorch'...
17:43:12.610 | INFO | prefect.infrastructure.docker-container - Creating Docker container 'prudent-goshawk'...
17:43:12.679 | INFO | prefect.infrastructure.docker-container - Docker container 'prudent-goshawk' has status 'created'
17:43:12.934 | INFO | prefect.agent - Completed submission of flow run '64e545de-27ff-4d51-85d6-cec4d8eb0afe'
17:43:12.949 | INFO | prefect.infrastructure.docker-container - Docker container 'prudent-goshawk' has status 'running'
/opt/conda/bin/python: Error while finding module specification for 'prefect.engine' (ModuleNotFoundError: No module named 'prefect')
Adding prefect to the container block extra pip packages doesnt help:
{
"EXTRA_PIP_PACKAGES": "prefect"
}
Mason Menges
11/04/2022, 3:58 PMBianca Hoch
11/04/2022, 3:59 PMBoris Tseytlin
11/07/2022, 4:35 PM/usr/local/bin/python: No module named prefect.engine.__main__; 'prefect.engine' is a package and cannot be directly executed
Mason Menges
11/07/2022, 4:40 PMBoris Tseytlin
11/07/2022, 4:50 PMimport os
from prefect import flow, get_run_logger
from prefect.deployments import Deployment
from prefect.blocks.core import Block
from prefect.infrastructure.docker import DockerContainer
docker_container_block = DockerContainer.load("ml-docker")
@flow
def train_model_flow():
import torch
logger = get_run_logger()
<http://logger.info|logger.info>("CUDA Available: %s", torch.cuda.is_available())
deployment = Deployment.build_from_flow(
flow=train_model_flow,
name="train_model_flow",
work_queue_name="test",
infrastructure=docker_container_block,
)
if __name__ == "__main__":
deployment.apply()
This is the flow. I am running the deployment from Orion UIMason Menges
11/07/2022, 5:55 PMfrom prefect import flow, task
import os
from prefect import flow, get_run_logger
from prefect.deployments import Deployment
from prefect.blocks.core import Block
from prefect.filesystems import S3
from prefect.infrastructure.docker import DockerContainer
@flow
def train_model_flow():
import torch
logger = get_run_logger()
<http://logger.info|logger.info>("CUDA Available: %s", torch.cuda.is_available())
if __name__ == "__main__":
docker_container_block = DockerContainer.load("ml-docker")
storage = S3.load("awspersonal")
flow_deployment = Deployment.build_from_flow(
flow=train_model_flow,
name="train_model_flow",
work_queue_name="test",
infrastructure=docker_container_block,
storage=storage,
ignore_file = ".prefectignore"
)
flow_deployment.apply()
with these packages on the ml-docker container:
{
"EXTRA_PIP_PACKAGES": "s3fs torch"
}
s3fs is necessary for s3 storage which is what i'm using, this could be different depending on the remote storage option you're using.
All that said particularly for production flows it's likely going to be more efficient to build a custom image that contains all of your external dependencies rather that installing them during the run.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by