René's URL Explorer Experiment


Title: Model training time increase more than 10x in some case · Issue #2412 · pythonnet/pythonnet · GitHub

Open Graph Title: Model training time increase more than 10x in some case · Issue #2412 · pythonnet/pythonnet

X Title: Model training time increase more than 10x in some case · Issue #2412 · pythonnet/pythonnet

Description: Environment Pythonnet version: 3.0.3 Python version: 3.10.14 Environment Versions PyTorch version: 2.3.0+cpu Is debug build: False Python platform: Windows-10-10.0.22631-SP0 Is CUDA available: False CUDA runtime version: 12.4.99 CUDA_MOD...

Open Graph Description: Environment Pythonnet version: 3.0.3 Python version: 3.10.14 Environment Versions PyTorch version: 2.3.0+cpu Is debug build: False Python platform: Windows-10-10.0.22631-SP0 Is CUDA available: Fals...

X Description: Environment Pythonnet version: 3.0.3 Python version: 3.10.14 Environment Versions PyTorch version: 2.3.0+cpu Is debug build: False Python platform: Windows-10-10.0.22631-SP0 Is CUDA available: Fals...

Opengraph URL: https://github.com/pythonnet/pythonnet/issues/2412

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Model training time increase more than 10x in some case","articleBody":"### Environment\r\n\r\n-   Pythonnet version: 3.0.3\r\n-   Python version: 3.10.14\r\n-   Environment Versions\r\n    PyTorch version: 2.3.0+cpu\r\n    Is debug build: False\r\n    Python platform: Windows-10-10.0.22631-SP0\r\n    Is CUDA available: False\r\n    CUDA runtime version: 12.4.99\r\n    CUDA_MODULE_LOADING set to: N/A\r\n    GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4060 Laptop GPU\r\n    Nvidia driver version: 556.12\r\n    cuDNN version: C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.4\\bin\\cudnn_ops_train64_8.dll\r\n    HIP runtime version: N/A\r\n    MIOpen runtime version: N/A\r\n    Is XNNPACK available: True\r\n    \r\n    Versions of relevant libraries:\r\n    [pip3] numpy==1.26.4\r\n    [pip3] torch==2.3.0\r\n    [pip3] torchaudio==2.3.0\r\n    [pip3] torchvision==0.18.0\r\n    [conda] blas 1.0 mkl\r\n    [conda] mkl 2021.4.0 pypi_0 pypi\r\n    [conda] mkl-service 2.4.0 py310h2bbff1b_1\r\n    [conda] mkl_fft 1.3.8 py310h2bbff1b_0\r\n    [conda] mkl_random 1.2.4 py310h59b6b97_0\r\n    [conda] numpy 1.26.4 py310h055cbcc_0\r\n    [conda] numpy-base 1.26.4 py310h65a83cf_0\r\n    [conda] torch 2.3.0 pypi_0 pypi\r\n    [conda] torchaudio 2.3.0 pypi_0 pypi\r\n    [conda] torchvision 0.18.0 pypi_0 pypi\r\n-   Operating System:\r\n    OS: Microsoft Windows 11 \r\n    GCC version: Could not collect\r\n    Clang version: Could not collect\r\n    CMake version: version 3.29.0-rc3\r\n    Libc version: N/A\r\n\r\n-   .NET Runtime:\r\n     .NET framework 4.8\r\n```python\r\nimport torch\r\npara =torch.Tensor(initial_para)\r\nx,y  = torch.tensor(x),torch.relu(torch.tensor(y))\r\npara.requires_grad = True\r\nloss = torch.nn.MSELoss()\r\noptimizer = torch.optim.Adam([para], lr=lr)\r\nfor i in `range(max_iter):`\r\n    y_fit = multi_gaussian(x,para)\r\n    l = loss(y_fit,y)\r\n    try:\r\n        if torch.isnan(l) or torch.isinf(l) :\r\n            print(\"l is nan or inf\")\r\n            break\r\n        l.backward()\r\n        optimizer.step()\r\n        optimizer.zero_grad()\r\n    except:\r\n        break\r\ndef multi_gaussian(x, params):\r\n    y = torch.zeros_like(x)\r\n    for i in range(0, params.shape[0], 3):\r\n        g = gaussian(x, params[i], params[i + 1], params[i + 2])\r\n        if torch.any(torch.isnan(g)) or torch.any(torch.isinf(g)):\r\n            continue\r\n        y = y + g\r\n    return y\r\ndef gaussian(x,center,amp,variance, offset = None):\r\n    return amp*torch.exp(-(x-center)**2/(variance ))\r\n```\r\n\r\n\r\n### Details\r\nHi, im using pytorch to fit gaussian mixture model. It works perfect via directly run main.py. My data had length of 1024, and it only took less than 0.1 s to fit the model. However, a strange issue occurred when I using PythonNet package in CSharp. After the python environment was initialized, the main.py was also successfully runned. But the time for model fit increased to nearly 1.8 s, 18 times slower than previous condition.\r\nWhile i used another fit methed named scipy.optimize.curve_fit method, it tooks almost the same time (0.03 s) as run main.py directly or by CSharp code call. I was so confused by the difference, and I want to know if there is way to solve the problem.\r\n\r\n(By the way, im coding my program in net4.8 framework, i cant using torchsharp in Csharp which need net6.0).\r\n\r\nThank a lot!\r\n","author":{"url":"https://github.com/s1030512149","@type":"Person","name":"s1030512149"},"datePublished":"2024-07-05T03:12:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2412/pythonnet/issues/2412"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d9bb172b-3060-34dc-a399-bd4866146927
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDAE6:8F24B:3DD4B04:564CB35:69713274
html-safe-nonce4f0d57c403e1938517d3e3dadb355e12bc0c19e57de7d7e22c8fe9051cf229a3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUU2OjhGMjRCOjNERDRCMDQ6NTY0Q0IzNTo2OTcxMzI3NCIsInZpc2l0b3JfaWQiOiIzODQ5ODgzMzQ1ODcyODI2OTk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac068d46ebf085b11781301fe96e1a906beb826d21c4cd483fb7bf9218edb77224
hovercard-subject-tagissue:2391687290
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/2412/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9683d036e42d43f03e0ad6482fd0ccbe27b8e3bec32c1d02acbaa9cbb0707b07/pythonnet/pythonnet/issues/2412
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9683d036e42d43f03e0ad6482fd0ccbe27b8e3bec32c1d02acbaa9cbb0707b07/pythonnet/pythonnet/issues/2412
og:image:altEnvironment Pythonnet version: 3.0.3 Python version: 3.10.14 Environment Versions PyTorch version: 2.3.0+cpu Is debug build: False Python platform: Windows-10-10.0.22631-SP0 Is CUDA available: Fals...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernames1030512149
hostnamegithub.com
expected-hostnamegithub.com
None0c91dba94f720b71e069760db74b45f0f69e50caa632dc4e976d5bf46c8242ee
turbo-cache-controlno-preview
go-importgithub.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git
octolytics-dimension-user_id6050430
octolytics-dimension-user_loginpythonnet
octolytics-dimension-repository_id14748123
octolytics-dimension-repository_nwopythonnet/pythonnet
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14748123
octolytics-dimension-repository_network_root_nwopythonnet/pythonnet
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasee6c1902093917264567791cc30776acd1b2490c9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/pythonnet/pythonnet/issues/2412#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F2412
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F2412
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pythonnet%2Fpythonnet
Reloadhttps://patch-diff.githubusercontent.com/pythonnet/pythonnet/issues/2412
Reloadhttps://patch-diff.githubusercontent.com/pythonnet/pythonnet/issues/2412
Reloadhttps://patch-diff.githubusercontent.com/pythonnet/pythonnet/issues/2412
pythonnet https://patch-diff.githubusercontent.com/pythonnet
pythonnethttps://patch-diff.githubusercontent.com/pythonnet/pythonnet
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpythonnet%2Fpythonnet
Fork 770 https://patch-diff.githubusercontent.com/login?return_to=%2Fpythonnet%2Fpythonnet
Star 5.4k https://patch-diff.githubusercontent.com/login?return_to=%2Fpythonnet%2Fpythonnet
Code https://patch-diff.githubusercontent.com/pythonnet/pythonnet
Issues 155 https://patch-diff.githubusercontent.com/pythonnet/pythonnet/issues
Pull requests 18 https://patch-diff.githubusercontent.com/pythonnet/pythonnet/pulls
Discussions https://patch-diff.githubusercontent.com/pythonnet/pythonnet/discussions
Actions https://patch-diff.githubusercontent.com/pythonnet/pythonnet/actions
Projects 0 https://patch-diff.githubusercontent.com/pythonnet/pythonnet/projects
Wiki https://patch-diff.githubusercontent.com/pythonnet/pythonnet/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/pythonnet/pythonnet/security
Please reload this pagehttps://patch-diff.githubusercontent.com/pythonnet/pythonnet/issues/2412
Insights https://patch-diff.githubusercontent.com/pythonnet/pythonnet/pulse
Code https://patch-diff.githubusercontent.com/pythonnet/pythonnet
Issues https://patch-diff.githubusercontent.com/pythonnet/pythonnet/issues
Pull requests https://patch-diff.githubusercontent.com/pythonnet/pythonnet/pulls
Discussions https://patch-diff.githubusercontent.com/pythonnet/pythonnet/discussions
Actions https://patch-diff.githubusercontent.com/pythonnet/pythonnet/actions
Projects https://patch-diff.githubusercontent.com/pythonnet/pythonnet/projects
Wiki https://patch-diff.githubusercontent.com/pythonnet/pythonnet/wiki
Security https://patch-diff.githubusercontent.com/pythonnet/pythonnet/security
Insights https://patch-diff.githubusercontent.com/pythonnet/pythonnet/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/2412
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/2412
Model training time increase more than 10x in some casehttps://patch-diff.githubusercontent.com/pythonnet/pythonnet/issues/2412#top
https://github.com/s1030512149
https://github.com/s1030512149
s1030512149https://github.com/s1030512149
on Jul 5, 2024https://github.com/pythonnet/pythonnet/issues/2412#issue-2391687290
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.