Skip to content

Commit

Permalink
Adding GPU Validation
Browse files Browse the repository at this point in the history
Add GPU Existence Validation
  • Loading branch information
AndrewPlayer3 authored Jul 14, 2021
2 parents b684df9 + 8dc2bca commit c599825
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/andrewplayer3/back_projection/compare/v0.0.0...develop) -- likely 0.0.1

### Added
-- Added validation for gpu existance (defaults to cpu if none exists)
21 changes: 16 additions & 5 deletions back_projection/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import argparse
import logging
import os
import subprocess
from pathlib import Path
from zipfile import ZipFile

Expand All @@ -30,9 +31,19 @@ def back_projection(granule: str, username: str, password: str, use_gpu: bool) -
file.write(output_string)
file.close()

gpu_exists = False
if use_gpu:
# grab gpu number, -1 if there isn't one
proc = subprocess.Popen(HOME+"/sentinel/bestgpu.sh", stdout=subprocess.PIPE, shell=True)
(bestGPU, err) = proc.communicate()
bestGPU = str(int(bestGPU.strip()))
print("GPU: ", bestGPU)
if bestGPU != "-1":
gpu_exists = True

# Run the back_projection through sentinel_cpu.py or sentinel_gpu.py VV
run_backprojection = ""
if use_gpu:
if use_gpu and gpu_exists:
print("RUNNING WITH GPU")
print("----------------")
run_backprojection = HOME + "/sentinel/sentinel_gpu.py"
Expand All @@ -45,8 +56,8 @@ def back_projection(granule: str, username: str, password: str, use_gpu: bool) -
print("Command: ", run_backprojection)
ret = os.system(run_backprojection)

# Convert each gslc to a multiband tiff
# (band 1: complex, band 2: real, band 3: amplitude)
# create a amplitude tiff
# band 1: amplitude
make_tiff = "python3 " + HOME + "/make_tiff.py " + granule + ".geo "
make_tiff += "elevation.dem.rsc " + granule
print(make_tiff + "_VV.tiff")
Expand All @@ -60,8 +71,8 @@ def back_projection(granule: str, username: str, password: str, use_gpu: bool) -
print("Command: ", run_backprojection)
ret = os.system(run_backprojection)

# Convert each gslc to a multiband tiff
# (band 1: complex, band 2: real, band 3: amplitude)
# create amplitude tiff
# band 1: amplitude
print(make_tiff + "_VH.tiff")
ret = os.system(make_tiff + "_VH.tiff")

Expand Down

0 comments on commit c599825

Please sign in to comment.