Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command for running via docker #10

Open
daspk04 opened this issue Oct 9, 2019 · 6 comments
Open

Command for running via docker #10

daspk04 opened this issue Oct 9, 2019 · 6 comments
Labels
docker Questions related to the use of otbtf docker images Documentation Request for more documentation good first issue Good for newcomers

Comments

@daspk04
Copy link
Contributor

daspk04 commented Oct 9, 2019

Hello,
I did try to run via docker but it shows error as ''cannot open file" or the "file doesn't exit". I'm not sure if it is the right way to forward input files in the folder in host to docker container. If you could help it would be great.

Screenshot from 2019-10-10 01-25-25

@remicres
Copy link
Owner

In you host, you must set the correct rights to the folders and files used inside the container.
What you can do: Start your docker container in interactive mode. Once in your docker container, note the group id (GID) of the folder/file you want to access. Then, create a new group for this GID in your docker container. After that, just add the user (otbuser) in the group owner. Commit your changes (docker commit) then you rights should be Ok.

@remicres remicres added good first issue Good for newcomers help wanted Extra attention is needed labels Oct 15, 2019
@remicres remicres pinned this issue Oct 15, 2019
@daspk04
Copy link
Contributor Author

daspk04 commented Oct 16, 2019

Thank you for helping. As you pointed out the problem was with my host folder/files rights as well as I figured out the command for accessing the folder for input was also wrong. So first I gave the folder read, write and execute access.
"sudo chmod -R a+wrx /path/to the/folder". In my case it was
sudo chmod -R a+wrx/home/das/Das_Task

After that I executed all the commands and all worked. Below are the list commands that worked in my case.

Change Directory
pwd: ~/Das_Task/Deep_Learning_Examples
Step 1: Polygon Statistics
sudo docker run -u otbuser -v $(pwd):/home/otbuser mdl4eo/otbtf1.6 otbcli_PolygonClassStatistics -vec /home/otbuser/Data/Pookwe/Shapefiles/Ratoon_Mar1_2018_reprojected.shp -field OBJECTID -in /home/otbuser/Data/Pookwe/Images/SENTINEL2A_20180323-033825-637_L2A_T47QRU_stacked.tif -out /home/otbuser/vec_stats_objid.xml

Step 2: SampleSelection
sudo docker run -u otbuser -v $(pwd):/home/otbuser mdl4eo/otbtf1.6 otbcli_SampleSelection -vec /home/otbuser/Data/Pookwe/Shapefiles/Ratoon_Mar1_2018_reprojected.shp -field OBJECTID -in /home/otbuser/Data/Pookwe/Images/SENTINEL2A_20180323-033825-637_L2A_T47QRU_stacked.tif -instats /home/otbuser/vec_stats_objid.xml -out /home/otbuser/points.shp

Step 3: PatchExtraction
sudo docker run -u otbuser -v $(pwd):/home/otbuser mdl4eo/otbtf1.6 otbcli_PatchesExtraction -source1.il /home/otbuser/Data/Pookwe/Images/SENTINEL2A_20180323-033825-637_L2A_T47QRU_stacked.tif -source1.patchsizex 16 -source1.patchsizey 16 -vec /home/otbuser/points.shp -field OBJECTID -source1.out /home/otbuser/samp_patches_16X16.tif -outlabels /home/otbuser/samp_patches_labels.tif

Change Dircetory
pwd: ~/Das_Task
Step 4: Create Model for Training
sudo docker run -u otbuser -v $(pwd):/home/otbuser mdl4eo/otbtf1.6 python /home/otbuser/OTB_DeepLearn/otbtf-master/python/create_savedmodel_simple_cnn.py --nclasses 2 --outdir /home/otbuser/Deep_Learning_Examples/SavedModels

Step 5: Train Model
sudo docker run -u otbuser -v $(pwd):/home/otbuser mdl4eo/otbtf1.6 otbcli_TensorflowModelTrain -model.dir /home/otbuser/Deep_Learning_Examples/SavedModels -training.targetnodes optimizer -training.source1.il /home/otbuser/Deep_Learning_Examples/samp_patches_16X16.tif -training.source1.patchsizex 16 -training.source1.patchsizey 16 -training.source1.placeholder x -training.source2.il /home/otbuser/Deep_Learning_Examples/samp_patches_labels.tif -training.source2.patchsizex 1 -training.source2.patchsizey 1 -training.source2.placeholder y -model.saveto /home/otbuser/Deep_Learning_Examples/SavedModels/variables/variables

Step 6: Model Serve
sudo docker run -u otbuser -v $(pwd):/home/otbuser mdl4eo/otbtf1.6 otbcli_TensorflowModelServe -source1.il /home/otbuser/Deep_Learning_Examples/Data/Pookwe/Images/SENTINEL2A_20180323-033825-637_L2A_T47QRU_stacked.tif -source1.placeholder x -source1.rfieldx 16 -source1.rfieldy 16 -model.dir /home/otbuser/Deep_Learning_Examples/SavedModels -output.names prediction -out /home/otbuser/Deep_Learning_Examples/outmap.tif uint8

@remicres
Copy link
Owner

I'm glad this helped! I had a few struggles myself with file permissions inside/outside the docker container.
Just in case: I have updated the README.md with the new docker images (OTBTF r1.7). There is new cuda-enabled docker image, suited for NVIDIA GPUs. A post also some little tricks & tips related to docker containers in this post

@daspk04
Copy link
Contributor Author

daspk04 commented Oct 17, 2019

Thank you for the information. The blog was really helpful. At present for some reason my graphic card isn't working. I have GTX 1050Ti may be because it is not compatible with my motherboard or may be faulty although the GPU fan keeps on running. So I wonder if I install the OTBTF r1.7:GPU without graphics card it should also work fine right.? I will not pass the parameter "runtime=nvidia" during docker run. Or should I use OTBTF r1.7:CPU until I have a NVIDIA GPU..?

@remicres
Copy link
Owner

I think that you can run it without the nvidia runtime, it should behave as the cpu version.
Regarding the GTX1050Ti issue, maybe you need to start from a clean platform with the latest drivers, cuda version, etc.

@daspk04
Copy link
Contributor Author

daspk04 commented Oct 17, 2019

Thank you. I did install the OTBTF r1.7:gpu. But I had to create an ''otbuser" inside the container. I did follow the steps from OTBTF r1.6 mentioned as below.

# Add user otbuser # Replace 1001 with your user / group id
I wonder why it was removed from the OTBTF r1.7:gpu docker build file. Also in OTBTF r1.6 the working directory for the container was set during build i.e home/otbuser but in OTBTF r1.7 it wasn't set. So I have to pass working directory path for each docker run command for example
sudo docker run -u otbuser -w="/home/otbuser/" -v $(pwd):/home/otbuser mdl4eo/otbtf1.7:gpu otbcli_PolygonClassStatistics -vec /home/otbuser/Data/Pookwe/Shapefiles/Ratoon_Jan_Feb_Mar1_reprojected.shp -field P_M -in /home/otbuser/Data/Pookwe/Images/SENTINEL2A_20180323-033825-637_L2A_T47QRU_stacked.tif -out /home/otbuser/Output/1.Polygon_stats/vec_stats_objid.xml

But I can run all the commands. Thank you again.

@remicres remicres added the docker Questions related to the use of otbtf docker images label Mar 22, 2020
@remicres remicres removed the help wanted Extra attention is needed label Apr 12, 2021
@remicres remicres added the Documentation Request for more documentation label May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Questions related to the use of otbtf docker images Documentation Request for more documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants