port in use: try to test/run torchserve in colab (Torchserve stopped. java.io.IOException: Failed to bind to address: http://127.0.0.1:8080)
Is there a workaround to run/dev in colab? Can't get it to run on windows (see previous issue I just entered, so moved to colab....still fails).
Followed all pip setup and requirements in readme.
!torchserve --start --ncs --model-store model_store --models densenet161.mar
result:
2020-05-14 05:28:41,971 [INFO ] main org.pytorch.serve.ModelServer - TS Home: /usr/local/lib/python3.6/dist-packages Current directory: /content Temp directory: /tmp Number of GPUs: 0 Number of CPUs: 2 Max heap size: 3256 M Python executable: /usr/bin/python3 Config file: N/A Inference address: http://127.0.0.1:8080 Management address: http://127.0.0.1:8081 Model Store: /content/model_store Initial Models: densenet161.mar Log dir: /content/logs Metrics dir: /content/logs Netty threads: 0 Netty client threads: 0 Default workers per model: 2 Blacklist Regex: N/A Maximum Response Size: 6553500 Maximum Request Size: 6553500 2020-05-14 05:28:42,050 [INFO ] main org.pytorch.serve.ModelServer - Loading initial models: densenet161.mar 2020-05-14 05:28:44,470 [DEBUG] main org.pytorch.serve.wlm.ModelVersionedRefs - Adding new version 1.0 for model densenet161 2020-05-14 05:28:44,470 [DEBUG] main org.pytorch.serve.wlm.ModelVersionedRefs - Setting default version to 1.0 for model densenet161 2020-05-14 05:28:44,471 [INFO ] main org.pytorch.serve.wlm.ModelManager - Model densenet161 loaded. 2020-05-14 05:28:44,471 [DEBUG] main org.pytorch.serve.wlm.ModelManager - updateModel: densenet161, count: 2 2020-05-14 05:28:44,486 [INFO ] main org.pytorch.serve.ModelServer - Initialize Inference server with: EpollServerSocketChannel. 2020-05-14 05:28:44,784 [INFO ] W-9000-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - Listening on port: /tmp/.ts.sock.9000 2020-05-14 05:28:44,787 [INFO ] W-9000-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - [PID]287 2020-05-14 05:28:44,787 [INFO ] W-9000-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - Torch worker started. 2020-05-14 05:28:44,788 [DEBUG] W-9000-densenet161_1.0 org.pytorch.serve.wlm.WorkerThread - W-9000-densenet161_1.0 State change null -> WORKER_STARTED 2020-05-14 05:28:44,792 [INFO ] W-9000-densenet161_1.0 org.pytorch.serve.wlm.WorkerThread - Connecting to: /tmp/.ts.sock.9000 2020-05-14 05:28:44,820 [INFO ] W-9000-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - Python runtime: 3.6.9 2020-05-14 05:28:44,833 [INFO ] W-9000-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - Connection accepted: /tmp/.ts.sock.9000. 2020-05-14 05:28:44,853 [INFO ] W-9001-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - Listening on port: /tmp/.ts.sock.9001 2020-05-14 05:28:44,857 [INFO ] W-9001-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - [PID]286 2020-05-14 05:28:44,857 [INFO ] W-9001-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - Torch worker started. 2020-05-14 05:28:44,858 [INFO ] W-9001-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - Python runtime: 3.6.9 2020-05-14 05:28:44,858 [DEBUG] W-9001-densenet161_1.0 org.pytorch.serve.wlm.WorkerThread - W-9001-densenet161_1.0 State change null -> WORKER_STARTED 2020-05-14 05:28:44,859 [INFO ] W-9001-densenet161_1.0 org.pytorch.serve.wlm.WorkerThread - Connecting to: /tmp/.ts.sock.9001 2020-05-14 05:28:44,870 [INFO ] W-9001-densenet161_1.0-stdout org.pytorch.serve.wlm.WorkerLifeCycle - Connection accepted: /tmp/.ts.sock.9001. 2020-05-14 05:28:46,988 [INFO ] main org.pytorch.serve.ModelServer - Torchserve stopped. java.io.IOException: Failed to bind to address: http://127.0.0.1:8080 at org.pytorch.serve.ModelServer.initializeServer(ModelServer.java:258) at org.pytorch.serve.ModelServer.start(ModelServer.java:318) at org.pytorch.serve.ModelServer.startAndWait(ModelServer.java:102) at org.pytorch.serve.ModelServer.main(ModelServer.java:83) Caused by: io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use at io.netty.channel.unix.Errors.newIOException(Errors.java:122) at io.netty.channel.unix.Socket.bind(Socket.java:287) at io.netty.channel.epoll.AbstractEpollChannel.doBind(AbstractEpollChannel.java:688) at io.netty.channel.epoll.EpollServerSocketChannel.doBind(EpollServerSocketChannel.java:70) at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:558) at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1358) at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501) at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486) at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:1019) at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:254) at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:309) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)
@lessw2020 : TorchServe by-default uses 8080 and 8081 ports for inference and management apis respectively.
From the above log trace, the 8080 port is already in use by some other process in your environment. You can configure custom ports while starting TorchServe as follows :
- Create a config.properties file
- Add following config properties
inference_address=http://127.0.0.1:<your_custom_port>
management_address=http://127.0.0.1:<your_custom_port>
- Start torchserve with following command :
torchserve --start --ncs --model-store model_store --models densenet161.mar --ts-config config.properties
For more details on all configurable properties refer : TorchServe Configuration Doc
Thanks will test tomorrow, much appreciated.
@harshbafna Lets include this in upcoming troubleshooting guide as well #215
worked like a champ, thanks very much. (I'll leave open if you want to reference for the troubleshooting guide) but issue is definitely resolved.
I had the same issue even after setting new addresses for inference_address, management_address, and metrics_address. After digging for a while, I noticed that port 7070 was occupied by the Anydesk application. To check the occupied ports on your device, run the following command:
sudo lsof -i -P -n | grep LISTEN
I added the following lines to the config.properties, and it resolved the bind failure:
grpc_inference_port=7000
grpc_management_port=7001
The full content of my config.properties file:
inference_address=http://0.0.0.0:8000
management_address=http://0.0.0.0:8001
metrics_address=http://0.0.0.0:8002
grpc_inference_port=7000
grpc_management_port=7001