Reputation: 61
I am using selenium to open a website. Specifically:
https://storage.googleapis.com/tfjs-models/demos/posenet/camera.html
But when it open it using headless mode, it displays following error:
[0513/155639.694:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 1 time(s)
DevTools listening on ws://127.0.0.1:6573/devtools/browser/58f34b20-1a05-4bf0-8e64-1b5a5028b1f6
[0513/155639.710:ERROR:cache_util_win.cc(21)] Unable to move the cache: Access is denied. (0x5)
[0513/155639.710:ERROR:cache_util.cc(138)] Unable to move cache folder C:/Users/Tazim Fatima/AppData/Local/Google/Chrome/User Data\Default\GPUCache to C:/Users/Tazim Fatima/AppData/Local/Google/Chrome/User Data\Default\old_GPUCache_000
[0513/155639.710:ERROR:disk_cache.cc(184)] Unable to create cache
[0513/155639.710:ERROR:shader_disk_cache.cc(606)] Shader Cache Creation failed: -2
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 2 time(s)
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 3 time(s)
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 4 time(s)
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 5 time(s)
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 6 time(s)
[0513/155639.725:ERROR:browser_gpu_channel_host_factory.cc(153)] Failed to launch GPU process.
[0513/155642.754:ERROR:service_worker_storage.cc(1624)] Failed to delete the database: Database IO error`enter code here`
After lots of searching, i tried:
options.add_argument("--disable-user-media-security=true")
options.add_argument('--headless')
options.add_argument("--no-sandbox")
options.add_argument("--use-fake-ui-for-media-stream")
options.add_argument("--disable-gpu")
options.add_argument("--disable-software-rasterizer")
options.add_argument('--disable-gpu')
options.add_argument("--window-size=1280,1024")
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--ignore-gpu-blacklist')
options.add_argument('--use-gl')
options.add_argument("--user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data")
driver = webdriver.Chrome(options=options)
driver.maximize_window()
driver.set_window_size(1200, 600)
driver.set_window_size(1280, 1024)
driver.get("https://storage.googleapis.com/tfjs-models/demos/posenet/camera.html")
Of course not all arguments at once but using different chunks at different times. Though one thing to note here is that when i use the argument --no-sandbox, The error changes to
DevTools listening on ws://127.0.0.1:1849/devtools/browser/426a187c-243f-42e3-a0b7-60c4f8dc73b2
[0513/163007.734:ERROR:gles2_cmd_decoder.cc(3610)] ContextResult::kFatalFailure: fail_if_major_perf_caveat + swiftshader
[0513/163007.742:ERROR:gles2_cmd_decoder.cc(3610)] ContextResult::kFatalFailure: fail_if_major_perf_caveat + swiftshader
[0513/163007.754:ERROR:gles2_cmd_decoder.cc(3610)] ContextResult::kFatalFailure: fail_if_major_perf_caveat + swiftshader
[0513/163007.758:INFO:CONSOLE(20)] "Initialization of backend webgl failed", source: https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js (20)
[0513/163007.758:INFO:CONSOLE(20)] "Error: WebGL is not supported on this device
at new e (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:294522)
at Object.factory (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:346621)
at t.initializeBackend (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:43098)
at t.initializeBackendsAndReturnBest (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:44537)
at t.get [as backend] (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:41137)
at t.makeTensor (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:48217)
at Tn (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:81890)
at Dn (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:81021)
at o (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:491592)
at Object.Pp [as decodeWeights] (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js:20:491626)", source: https://storage.googleapis.com/tfjs-models/demos/posenet/camera.cb338cd2.js (20)
And it works. But compared to non headless mode, it is very very slow.
And i can't trade with speed. How can i solve this problem?
Upvotes: 6
Views: 19459
Reputation: 193298
This error message...
[0513/155639.710:ERROR:cache_util_win.cc(21)] Unable to move the cache: Access is denied. (0x5)
[0513/155639.710:ERROR:cache_util.cc(138)] Unable to move cache folder C:/Users/Tazim Fatima/AppData/Local/Google/Chrome/User Data\Default\GPUCache to C:/Users/Tazim Fatima/AppData/Local/Google/Chrome/User Data\Default\old_GPUCache_000
[0513/155639.710:ERROR:disk_cache.cc(184)] Unable to create cache
[0513/155639.710:ERROR:shader_disk_cache.cc(606)] Shader Cache Creation failed: -2
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 2 time(s)
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 3 time(s)
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 4 time(s)
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 5 time(s)
[0513/155639.725:WARNING:gpu_process_host.cc(1204)] The GPU process has crashed 6 time(s)
[0513/155639.725:ERROR:browser_gpu_channel_host_factory.cc(153)] Failed to launch GPU process.
[0513/155642.754:ERROR:service_worker_storage.cc(1624)] Failed to delete the database: Database IO error
...implies that ChromeDriver/Chrome process was unable to move cache folder ..\Default\GPUCache
to ../AppData/Local/Google/Chrome/User Data\Default\old_GPUCache_000
.
As per the article Headless: make --disable-gpu flag unnecessary a lot of articles, documentation and guides recommended the usage of --disable-gpu
flag as libosmesa.so
wasn't present. With the availability of the merge headless: Switch from osmesa to SwiftShader this flag was no longer necessary on Linux or macOS. Moving forward with the availability of the merge Always use SwiftShader for headless Chrome this flag was unnecessary on Windows even.
As a solution you need to remove the following arguments:
--disable-gpu
--disable-software-rasterizer
You can find a couple of relevant discussions in:
Additionally, when trying to access a specific Chrome Profile instead of mentioning the top User Data
directory you need to go one step deeper and mention the profile directory e.g ../User Data/Profile 2
as follows:
options.add_argument("--user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data/Profile 2")
You can find a couple of relevant discussions in:
Upvotes: 3