MSI
October 15, 2021, 8:15pm
28
@Bhack As you suggested, I tried to follow your provided TF-serving technique. But faced some problem there. But from another website implemented the TF-Serving with flask. As far as I learnt we can’t use tflite in TF-serving. As a result I converted my h5(size was 42.0 MB) to pb(and required format). Which worked fine. But still slow in process. Do you think my PC needs to be more stronger ?
NB: Current PC config 8gb ram, 1TB HDD, 4gb(grapics) !
MSI
October 15, 2021, 8:17pm
29
Modified the frame generate code for prediction like below. Is there any problem ?
def generate_frames(frame):
img_face = cv2.resize(frame,(256,256))
img_face = cv2.cvtColor(img_face, cv2.COLOR_BGR2RGBA)
#converting into float32
img_face_f = (img_face/255.0).astype(np.float32)
img = img_face_f[:,:,:3]
payload = {
"instances": [{'input_1': img.tolist()}]
}
r = requests.post('http://localhost:8501/v1/models/model_name:predict', json=payload)
mask= json.loads(r.content.decode('utf-8'))
mask= np.array(mask['predictions'])[0]
final_result = (mask*255).astype(np.uint8)
ret,buffer=cv2.imencode('.jpg',final_result)
frame=buffer.tobytes()
return frame
MSI
October 15, 2021, 8:21pm
31
Bhack:
What is you GPU?
NVIDIA- GeForce-940MX (4 GB DDR3 dedicated)
Bhack
October 15, 2021, 8:26pm
32
Do you have followed the TF serving for GPU steps?
Also if it is running correctly on GPU this specific model could be still relatively slow if your if your model is too heavy. See:
MSI
October 15, 2021, 8:30pm
33
Yes, I think ! I tried with tensorflow/serving:latest-gpu image.
Bhack
October 15, 2021, 8:59pm
34
check with nvidia-smi
that your GPU is occupied.
MSI
October 16, 2021, 7:19am
35
@Bhack I think you got the right point !! Somehow it’s not utilizing my GPU !!!
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 471.41 Driver Version: 471.41 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... WDDM | 00000000:01:00.0 Off | N/A |
| N/A 0C P8 N/A / N/A | 40MiB / 4096MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
After running the program! but what’s wrong with it !!
MSI
October 16, 2021, 7:56am
36
I think I missed the nvidia docker point !
1 Like
MSI
October 16, 2021, 9:48am
37
@Bhack Apart from this I saw when I am using tflite normally in my PC it’s not utilizing the GPU but the normal model does. What’s the point here?
Bhack
October 16, 2021, 12:02pm
38
Yes TFlite has not a Nvidia/CUDA GPU delegate currently.
On that GPU you need to use regular TF. See:
opened 01:35AM - 23 Nov 19 UTC
closed 10:28PM - 13 Dec 19 UTC
stat:awaiting tensorflower
type:support
comp:lite
Is TF Lite optimized for nvidia gpu's (as similar to TensorRT) and Intel CPUs. I… f not is there a list of supported hardware/accelerators out there?
MSI
October 18, 2021, 4:30pm
40
@Bhack Thinking about hair segment of mediapipe. But it’s available in Android & C++… Is there any way to use it in python ?
Bhack
October 18, 2021, 6:27pm
41
With serving you need to use a “regular” TF model:
opened 08:09AM - 21 Sep 20 UTC
closed 01:29PM - 12 Oct 20 UTC
stat:awaiting response
type:support
Hi,
I convert a pb model to tflite model and tflite runs faster on PC's CPU.
…
I'm wondering can I serve a tflite model by TF-Serving on PC?
Thank you
Bhack
October 18, 2021, 7:42pm
42
It is probably exoerimental but If you need a specific TFlite model you could try to conver your model with:
Then probably you could write your own service with TF.js node GPU:
MSI
December 5, 2021, 6:49am
44
@Bhack Thanks for all the suggestions. Can you please take a look on this issue? Thank you.
Bhack
December 5, 2021, 11:44am
45
Isn’t that one the same issue?
MSI
December 5, 2021, 2:15pm
46
No, this time normal model is working fine but when predicting for the first time after starting server it takes time !!
MSI
December 6, 2021, 9:06am
47
@Bhack Going through some confusion. Almost in every article, we can see they recommend the TF serving for deployment but when I should avoid it?
Bhack
December 6, 2021, 10:48am
48
You have Tensorflow serving or you can experiment with TF.js node
gdubey
September 16, 2022, 3:39am
50
@Bhack @George_Soloupis Any solution which helps in: Flask/FastAPI serving (cannot reload/refresh model)? Please help;
Tried removing all the possible references of objects related to interpreter (input_details, output_details) etc;