Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Detectron2 deploys the environment and installs

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how Detectron2 deploys the environment and installs it. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Part1: miscellaneous and fragmentary because Detectron2 can be "installed" in nature, that is, relevant contents in detectron2 can also be used in other file directories, so I adopted the following learning ideas. First, I set up a folder of detectron2_notebook and put it in the same directory with detectron2: 1. First of all, set up the detectron2_notebook folder and detectron2 project notebook, d2learn will put some code, notebook will store markdown2. Secondly, build the docker on the remote server, and set up two projects that can be debugged remotely through pycharm 3. 5. After that, install detectron2 using python setup.py develop in the remote installation

3.1 this ensures that local changes to detectron2 can take effect at the remote end.

3.2At the same time, it is convenient for you to change the detectron2 4. Scripts for training, testing, and using detectron2 will be set up in the notebook folder to facilitate the overall "packing" in the future.

Next, I will show you how to do this step by step.

Part2: install docker tron2, environment configuration

Sharp tools make good work. So before starting to learn, of course, it is necessary to seriously build a usable development environment. First of all, suppose you have a server that can use CUDA10 (there are a lot of videos with CUDA environment, which will not be discussed here). Generally speaking, a normal development environment is designed like this:

As shown in the figure, it can be divided into the following processes:

First, the docker container will be started in the server and several ports in the container will be exposed.

It is generally at least exposed:

22 port, convenient for pycharm ssh to connect to docker for remote debugging

At least one other port makes it easy to start jupyterlab to view files on the container and perform command line operations

Start jupyter lab in the container and access jupyter lab through chrome to facilitate file editing and modification (I can't use vim... at all)

Using pycharm to connect to the server makes it possible to use pycharm for remote debugging, which is easy to modify and debug code.

As for how to configure a dockerfile that supports detectron2 development, you can basically refer to the official version:

Https://github.com/facebookresearch/detectron2/blob/master/Dockerfile

On top of this, you need to do the following additional operations in the container:

Configure the container's ssh secret-free login here I use 14371 login because I mapped the container's port 22 to the server's port 14371 to launch jupyterlab, so that I can access through the web page on my computer. Similarly, I mapped the port started by jupyter in the container to the server's port 14374, pycharm configuration process.

After ensuring the availability of docker, the next step is to configure pycharm to support remote debugging. As this step is cumbersome, here are the relevant steps in detail.

2.1Configuring server upload path 2.2.Configuring server upload directory 2.3.Configuring remote debugging environment 2.5.Creating a new environment 2.6.Select ssh, setting it to the environment you just established, 2.7Select python3 with pytorch dependency in the container, and setting the uploaded directory to 2.3.Configuration2.9. confirm that the correct remote python compiler is used. Confirm that the project is mapped to the correct remote location 2.9 some notes

Notice that I put detectron2 and my own notebook in a folder and upload them to the server, which I find more convenient to manage, so that the code of the detectron2 I installed at the remote end comes from this local code, which is easy to change.

2.10 upload all data manually at once

The corresponding file structure should be visible in the remote host on the right

2.10 confirm whether the call can be made

Create a new hello_remote.py

Execution

Verify that the current execution information is to use the remote server to execute the remote file:

3. Installation of detectron2 3.1 installation dependence

In jupyter lab, create a new command line window (this shows the convenience of jupyter lab)

# first of all, make sure to have pytorch2.3 and torchvision, and then install the following dependencies

Pip3 install 'git+ https://github.com/facebookresearch/fvcore'

Pip install cython; pip install 'git+ https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'3.2 perform python3 install develop installation Note be sure to use develop3.3 here to ensure that detectron2 can be successfully importpart3: run demo, run out of the cover image!

First, copy predictor from detectron2/demo to the same directory, and copy cascade_mask_rcnn_R_50_FPN_1x.yaml from configs/Misc/ to the same level directory:

Second, in the remote server, put the model

Https://dl.fbaipublicfiles.com/detectron2/Misc/cascade_mask_rcnn_R_50_FPN_1x/138602847/model_final_e9d89b.pkldl.fbaipublicfiles.com

Download to the newly created model folder

Modify the copied yaml to point to the downloaded pkl

Then execute the following script:

Thank you for reading! This is the end of the article on "how to deploy the environment and install Detectron2". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report