I was trying to upload ultralytics to google cloud. I added ultralytics to my requirements.txt file. Then when I deploy my files to google cloud. It says installation complete. But after deploying... the console gives the following error (unable to watch for file changes in this large workspace). After that, the console goes offline. If I go online again, everything I do is reset.
1 Answers
Here's the fastest way (allows you to quickly deploy new models, just by changing a model version number):
Option 1:
- Train a YOLOv8 model, and upload weights to a Roboflow project (- What is Roboflow?):
https://docs.roboflow.com/upload-weights
- You'll have the ability to utilize multiple deployment options, such as cloud, edge device (i.e NVIDIA Jetson or Luxonis OAK), mobile device (iOS SDK), and other local devices or servers: https://docs.roboflow.com/inference-2.0-beta
Next, follow steps 1-5 below, and be sure you install the Roboflow Python SDK after step 5:
pip install roboflow
Run inference:
# accessing the model
rf = Roboflow(api_key="YOUR_API_KEY")
inference_project = rf.workspace().project("YOUR_PROJECT_NAME")
model = inference_project.version(1).model
# adjusting the model confidence threshold
model.confidence = 50
model.overlap = 25
# using the model
predictions = model.predict("PATH_TO_IMAGE").json()["predictions"]
- https://docs.roboflow.com/python#quick-start
- https://github.com/roboflow/roboflow-computer-vision-utilities/
- Video Inference: https://github.com/roboflow/video-inference
Option 2:
You can install ultralytics
in Google Cloud using a virtual machine (VM) and setting up the necessary environment. I've outlined the process below:
Create a Virtual Machine (VM):
- Navigate to the Google Cloud Console.
- From the navigation menu, select Compute Engine > VM Instances.
- Click on "Create Instance".
- Fill the necessary fields like
Name
,Region
,Machine type
, etc. - In the
Boot disk
section, choose anUbuntu
image, such asUbuntu 20.04
. - Allow full access to all Cloud APIs.
- Click "Create" to initiate your VM.
SSH into the VM:
- Once your VM is ready, click on the
SSH
button to access the command line.
- Once your VM is ready, click on the
Update and Upgrade your VM:
Run the command below to update the package lists for upgrades for packages that need upgrading, and for new packages that have just been updated or added to the repositories.
sudo apt-get update sudo apt-get upgrade
Install Necessary Libraries and Packages:
For an added check to ensure you can install everything, you should install some necessary libraries and packages such as
build-essential
andcmake
. Also, you should installpython3
andpip3
if they are not already installed.sudo apt-get install build-essential cmake sudo apt-get install python3-dev python3-pip
Install Git:
sudo apt-get install git
Install PyTorch and Torchvision:
Since
ultralytics
is built on PyTorch, you'll want to install PyTorch, along withtorchvision
.You can find the latest installation command for your configuration at the PyTorch website (https://pytorch.org/). Here's an example command:
pip3 install torch torchvision
Clone the
ultralytics
Repository:Now that you have everything ready, you can clone the
ultralytics
repository:git clone https://github.com/ultralytics/ultralytics.git
Navigate to the
ultralytics
Directory:After cloning, a new directory named
ultralytics
will be created. Navigate into it:cd ultralytics
Install the Required Python Packages:
pip3 install -r requirements.txt
Check the Installation:
To confirm the installation in your VM, run the following command to see if
ultralytics
can be run successfully for model inference, configure the command based on the model you are running:yolo predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'
If you want to use GPU acceleration, you need to create a VM with GPU and install necessary CUDA libraries based on the GPU model.
- P.S., YOLOv8 inference for Google VM - try this if you'd like to do object tracking: supervision - GitHub for YOLOv8 object tracking

- 191
- 3
-
Thanks for the suggestion. Is there a way to simply deploy my existing model to Roboflow without generating the dataset from scratch? – selcuk-sahin Jun 12 '23 at 08:06